Welcome to February update of Java on Visual Studio Code! We’d like to share a few new improvements to further enhance your productivity, including
- Dependency auto-completion and more Maven updates
- Performance improvements
- Standalone file supports
- Multiple source folders support
- Easy launch for multi-main-class projects
- Hide temporary files
- Bulk generate getters and setters
- Test configuration and report update
- Including IntelliCode to Java Extension Pack
Try these new features by installing Java Extension Pack with Visual Studio Code. See below for more details!
Managing your Maven Dependencies Easily
Editing pom.xml is a common task for developer when working with Maven project. To make it easier with Visual Studio Code, the Maven extension now supports code snippet as well as dependency auto-completion. The extension pulls plugin information from your local repository as well as Maven Central to help you choose artifacts and versions as you type.
Maven plugins and their goals are now listed in the explorer along with other Maven resources. You can execute the goals with just a few quick clicks.
Maven explorer now also allows you to switch between flat view and hierarchical view, to your preference.
Loading Extensions and Projects Faster
One of the key performance related scenarios we’re improving for editor performance is loading projects. Two improvements are introduced with this update.
- The load time of Java extensions is reduced by adopting webpack. All Visual Studio Code extensions are written in JavaScript/TypeScript. Recently, we started to adopt webpack to generate the production package, with code combined and minified. This dramatically reduced extension load time. Please update the extensions to the newest version, so you will get this improvement automatically.
- Thanks to the improvement made from upstream JDT project, we can now enable parallel build in Java Language Server. By doing so, the time of loading a project can be reduced. The build process is per project. You will get the most performance gain when you have multiple child projects in your workspace. To enable parallel build, open setting.json and set the option java.maxConcurrentBuilds to a numeric value. The recommended value is the number of CPU cores on your machine.
{ "java.maxConcurrentBuilds": 4 // on a 4-core machine }
Handling All Your Source Code
If you want to work with java files directly but don’t bother to create a project, we’ve now got you covered with improved standalone Java file support.
The solution is folder based, so all you need to do is open a folder with Visual Studio Code and all the Java files within the folder will be properly compiled. Then you will be free to run or debug them.
What if you have multiple sub-folders that have source code inside and want to have them handled correctly? Just add these folders to source path, then all the code inside those folders will be correctly compiled.
If you have multiple main classes in your workspace, you can have a special launch configuration to launch whatever is in the active editor. This comes handy when you use hot keys. Here’s the new configuration:
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}" // whatever main class in the active editor
}
Hide Temporary Files
After opening a project folder, some extra files will be generated by Java Language Server inside the folder to work properly. Now you can choose to hide those files in Visual Studio Code. When opening a project folder, Java Language Server will ask you how you would like to handle those temporary files. You can hide them globally or just within the current workspace or leave them as-is.
Bulk Generate Getters & Setters
More source actions were added to the language server. Now you can bulk generate getters and setters for all new member variables.
Easier Test Configuration and Report Navigation
Test configurations are very useful in special test setups. Those configurations were originally stored in launch.test.json, which generated lots of confusions according to the user feedback. We listened, and as a result, we deprecated launch.test.json, and replaced it with regular VS Code settings. Now, the test configurations stay in settings.json, which can be global or at the workspace level. And they look like this
"java.test.config": [
{
"name": "myTestConfiguration",
"workingDirectory": "${workspaceFolder}",
"args": [ "-c", "com.test" ],
"vmargs": [ "-Xmx512M" ],
"env": { "key": "value" },
},
{
// Another configuration entry...
}
]
For more details, visit Test Runner Configuration.
The updated test report now allows you to jump to the definition of a test case directly by click the link in the reports.
Including IntelliCode to Java Extension Pack
As we’ve introduced in our previous blog, IntelliCode saves you time by putting what you’re most likely to use at the top of your completion list. After releasing it 3 months ago, we see more and more developers adopting it with great feedbacks. Thus we decided to include it into our Java Extension Pack so more developers could benefit from AI-assisted coding.
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. You may take this survey to share your thoughts!
Visual Studio Code is a fast and lightweight code editor with great Java support from many extensions
- Java Extension Pack includes essential Java tools including Language Support for Java™ by Red Hat, Debugger for Java, Maven, Java Test Runner and IntelliCode Extension for Visual Studio Code.
- There’re also other Java related extensions you can choose from, including
- Tomcat and Jetty for quickly deploy and manage local app servers.
- In case you’re working on Spring Boot, there’re also great support provided by Pivotal and Microsoft available on Visual Studio Code including Spring Boot Tools, Spring Initializr and Spring Boot Dashboard.
- Java Dependencies provides you a package view of your Java project and helps you managing your dependencies.
- Checkstyle could be handy when you need coherence code style especially cross multiple team members.
- Learn more about Java on Visual Studio Code.
- Explore our step by step Java Tutorials on Visual Studio Code.
0 comments