Java on Visual Studio Code Update – November 2020

Yaojin Yang

Yaojin

Welcome to the update of Java on Visual Studio Code for November. In this update, we are excited to announce a new wizard for Java runtime configuration. Back to September, we published a blog clarifying: 1) Java 11 as minimum version of JDK is only required for running VS Code for Java; 2) VS Code continuously supports projects with JDK version 1.5 or above. In that blog, we also shared how to configure JDKs for your project and for running VS Code for Java respectively, which requires you to manually configure two settings in ‘settings.json’ file. Although the manual approach works, we are aware that improvements in overall experience are still needed, which results in the implementation of Java Runtime Configuration Wizard.

Java Runtime Configuration Wizard

Java runtime configuration wizard is part of Java Extension Pack. Make sure you have the extension pack installed. As a side note, we strongly recommend installing the extension pack or Coding Pack for Java for your Java development on VS Code. For details, please check here.

Load project into workspace

Click menu: Files->Open Folder… or Files->Open Workspace… to load project into workspace. When you see a thumbs up icon Image Thumbup2 on status bar, your project is loaded.

Open the wizard

Ctrl+Shift+P to launch command palette and then use command “Java: Configure Java Runtime” to launch the wizard.

Image JDK config wizard overview

Configure project JDK

Project JDKs tab on the wizard configures JDK for project. When your project uses Maven or Gradle, WorkSpace Overview lists the language version set by the build tool; Maven/Gradle Projects lists all eligible JDKs installed in your environment per the language version and also allows you to specify a JDK for your project.

Image Project JDKs view

Image Project JDK selection

Configure JDK for running VS Code for Java

Java Tooling Runtime tab allows you to specify runtime to run VS Code’s Java language tools, a.k.a. the Java Language Server. The tab only lists Java 11 or above JDKs installed in your environment, as required by the language server. Please, remember to reload VS Code to make change effective.

Image Java Tooling Runtime

Install JDK

Installed JDKs tab lists all JDKs in your environment found by the wizard.

Image Installed JDKs

To facilitate installing new JDK when needed, Install A JDK section offers multiple options.

Image Install A JDK

Other Enhancements

Automatically infer selection range from cursor position

Language Support for Java(TM) by Red Hat is able to infer selection range from cursor position now. As a result, expressions can be extracted and proposed by VS Code automatically for refactoring.

Image Infer selection

Support exporting JAR through custom task

Project manager for Java now supports exporting JAR through custom task, which allows you to have fine-grained control on how JAR can be exported for your project.

Image Exporting JAR using custom task

You can configure custom task by clicking menu: Terminal->Configure Tasks… and then selecting the exporting JAR task for your project. You can run custom task by clicking menu: Terminal->Run Task…, selecting Java, and then selecting the exporting JAR task.

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.

4 comments

Comments are closed. Login to edit/delete your existing comments