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

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube