X

How to set up VS Code for Java development in Windows

In my previous post, I covered how to set up Visual Studio Code for Java development in Ubuntu, in this post I will cover how to do it in Windows. It follows the same two steps as in Ubuntu:

  1. Install Extension Pack for Java
  2. Install a new Java SDK

Download and install Visual Studio Code

  • Go to the Visual Studio homepage and click “Download for Windows” download the Windows installer for Visual Studio Code.
  • Run the installer and follow the on-screen instructions to install VS Code (you may use the default values during the installation)

Install Extension Pack for Java

After you launch VS Code, click the Extension icon in the Activity Bar on the left side of VS Code:

Then in the search field type “Java” to get a list of extensions for Java development. From the list choose Extension Pack for Java, developed and maintained by Microsoft, then click the Install button to install the extension.

Install a new Java SDK

In VS Code, click View and choose Command Palette, and type in “Install New JDK” then select the first entry from the list to see a window as below:

Click the Download button to download the Adoptium’s Temurin OpenJDK installer. Run the installer and follow the on-screen instructions to install the Java SDK until you reach the screen as shown below:

In this screen, make sure to click “Set JAVA_HOME variable” and choose “Will be installed on local hard drive“, then continue to finish the installation.

After the installation, you can close the Install New JDK window in VS Code. To verify the installation of Java SDK, click Terminal->New Terminal in VS Code, then type “java -version” in the terminal window and press Enter, and you will the output as follows:

openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)

Note: The version number in your output might be different, depending on when you install the SDK.

Now, your VS Code is successfully configured for Java development.

0 0 votes
Article Rating
Jeffrey:
Related Post