News

VS Code Java Team Details 5 Best Dev Practices

Microsoft's Visual Studio Code team for Java development added a new Coding Pack for Java installer and detailed best practices for setting up a development environment.

Support for Java in Visual Studio Code is provided through a wide range of extensions, many of which are bundled in the Java Extension Pack.

Coding Pack for Java
[Click on image for larger view.] Coding Pack for Java (source: Microsoft).

The new Coding Pack for Java, meanwhile, installs VS Code, the AdoptOpenJDK Java Development Kit (JDK) and the "essential Java extensions" found in the Java Extension Pack. It can be used for a brand-new clean installation or for updating or repairing an existing development environment. The installer is available for Windows and for macOS, but be warned that clicking on those links may start an automatic download.

Along with announcing the new Coding Pack for Java installer, Yaojin Yang, senior program manager in the Developer Division at Microsoft, detailed five best practices for initial setup of a development environment, starting off with using the Coding Pack for Java. "When installation completes, you immediately have an integrated environment for your Java projects," he said. "The pack supports incremental updates by checking your environment firstly and only installs required pieces."

After explaining how VS Code uses two JDKs, boot (for running VS Code for Java) and project (for building projects), Yang listed other best practices including:
  • Check the "java.home" VS Code setting to ensure it points to a JDK with Java 11 or above if you have trouble with running VS Code for Java. To access that setting click on the menu item titled "File->Preferences->Settings" and search for "java.home" on the "User" tab.
  • Configure your project JDK using the VS Code setting "java.configuration.runtimes" found by clicking on the "File->Preferences->Settings" menu item and searching for "java.configuration.runtimes" on the "User" tab. "You can set multiple JDK versions, and VS Code will pick the best version per your default or project’s source level," Yang said.
  • Install the Java Extension Pack instead of installing individual extensions if you are coding on a Linux machine and thus can't use the Coding Pack for Java installer or otherwise just want to follow a manual process instead.
  • Use the Extension Guide for functionality not found in the Java Extension Pack, including adding more framework support, application server support or utility functions. To launch the wizard-like guide that recommends and installs extensions for specific functionality, click the "View->Command Palette ..." menu item and type in "Java: Extension Guide" in the pallette, which can also be launched by the CTRL+Shift+P keyboard command sequence.

Yang also provided advice on using the Project View that was introduced back in August along with the Extension Guide as part of an effort to improve the "getting started" experience.

See Yang's Oct. 15 blog post for more details on the above, along with advice for using different options to trigger "run or debug" and useful documentation such as:

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

Upcoming Events