Java on Visual Studio Code Update – May 2021

Yaojin Yang

Yaojin

Welcome to May’s updates on VS Code for Java. In this edition, we will share with you Java Formatter Settings editor and other cool features. Let’s start.

Java Formatter Settings

Today, changing a Java formatter setting on VS Code requires you going through an XML file with hundreds of options, manipulating the file, and applying change without being able to preview. This process is cumbersome and error prone. To fix the problem, we are introducing the Java Formatter Settings editor where options are categorized, and changes can be previewed.

To launch the editor, click Ctrl+Shift+P to open command palette, and then type “java: open java formatter settings with preview” on the palette and run the command. After change, right click on editor to select “Format Document”, or type “format document” on the palette and run the command to apply the change to your project.

Image formatterEditorGif

Generating Tests from Source File

In April’s update, we introduced automatically generating testing method templates from a test file. In May, we have further developed the feature to allow generating test file and testing method templates directly from a source file. You can right-click on source file editor to invoke context menu, select “Source Action…” and then “Generate Test…” to generate.

Image generateTestFromSource

Others

  • Customizing “classPaths” and “modulePaths” configurations via launch.json. The enhancement supports for predefined variables:
    • $Auto – Automatically resolve the classpaths or modulepaths of current project. This is default value.
    • $Runtime – Add classpaths or modulepaths within ‘runtime’ scope of current project.
    • $Test – Add classpaths or modulepaths within ‘test’ scope of current project.
    • !<path> – Exclude the specified path from classpaths.

Image classpath

  • Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. It is very popular for learning program languages, data analysis and machine learning, etc. If you are interested in using it for Java on VS Code, please follow the instructions.

Try it out

Please don’t hesitate to give it a try! Your feedback and suggestions are very important to us and will help shape our product in future.

 

1 comment

Leave a comment