Yang Yaojin from Microsoft VS Code Java Team
Welcome to the VS Code for Java update in May. This time, we’ll share with you the Java formatting Settings editor and other cool features. Let’s go.
Java Formatting Settings
Today, changing Java formatting Settings on VS Code requires you to browse through an XML file with hundreds of options, change the file, and apply the changes to your project without being able to preview them. This process is cumbersome and error-prone. To solve this problem, we introduced the Java Formatter Settings Editor. Formatting options are sorted in the editor, and changes can be previewed.
To launch the editor, click Ctrl+Shift+P to open the Command Palette, then type “Java: Open Java Formatter Settings with Preview” on the palette, and run the command. After making the changes, right-click the editor and select “Format Document”, or type “Format Document” on the command panel and run commands to apply the changes to your project.
Generate tests from source files
In the April update, we introduced automatic generation of test method templates from test files. In May, we developed this capability further, and now you can generate test files and test method templates directly from source files. You can right-click the Source file editing page and choose Source Action… Then select “Generate Test…” To generate.
other
- Configure the classPaths and modulePaths parameters in the launch.json file. Parameters support the following predefined values:
-$Auto – Automatically calculates the classpaths or modulePaths of the current item. This is the default option.
-$Runtime — Add classpaths or ModulePaths for the Runtime scope.
-$Test — Add classpaths or ModulePaths for the Test scope.
-! – Remove path from CLASspaths or ModulePaths.
- Jupyter Notebook is an open source project that allows you to create and share documents containing real-time code, equations, visualizations, and narrative text. It is very popular for learning programming languages, data analysis and machine learning. If you are interested in using it for Java in VS Code, follow the instructions.
For more information
Please don’t hesitate to give it a try! Your feedback and suggestions are very important to us and will help shape our products in the future.
- Learn more about Java on Visual Studio Code.
- Step by step explore the Java tutorial for Visual Studio Code.