The few times I used it, I disliked it. Coming from a full feature IDE like IntelliJ, it feels like a basic text editor. Many missing small things, or you need to install dozens of extensions. This might have changed as it evolves quite quickly, so I'd recommend trying anyway. Answer from gaelfr38 on reddit.com
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ languages โ€บ java
Java in Visual Studio Code
November 3, 2021 - VS Code provides essential language features such as code completion, refactoring, linting, formatting, and code snippets along with convenient debugging and unit test support. VS Code also integrates with tooling and frameworks such as Maven, ...
๐ŸŒ
Reddit
reddit.com โ€บ r/java โ€บ vs code for java: good or bad?
r/java on Reddit: VS Code for Java: good or bad?
July 18, 2023 -

Hey everybody,

I haven't tried vscode for java before, but I was wondering what others think of using it for an IDE?

I have used eclipse and intellij before, but was considering vscode. If you have tried it, what packages have you found useful, what are the things you like and what are your pain points using it?

I am going to experiment with it tomorrow and make a workspace in vscode for it.

Cheers!

๐ŸŒ
GitHub
github.com โ€บ redhat-developer โ€บ vscode-java
GitHub - redhat-developer/vscode-java: Java Language Support for Visual Studio Code
Java Language Support for Visual Studio Code. Contribute to redhat-developer/vscode-java development by creating an account on GitHub.
Starred by 2.2K users
Forked by 511 users
Languages ย  TypeScript 91.4% | JavaScript 5.5% | CSS 2.3% | Java 0.8%
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-project
Managing Java Projects in VS Code
November 3, 2021 - To get the complete Java language support in Visual Studio Code, you can install the Extension Pack for Java, which includes the Project Manager for Java extension.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-debugging
Running and debugging Java
November 3, 2021 - For details on how to get started ... with Java tutorial. By default, the debugger will run out-of-box by automatically finding the main class and generating a default launch configuration in memory to launch your application. If you would like to customize and persist your launch configuration, you can select the create a launch.json file link in the Run and Debug view. The launch.json file is located in a .vscode folder in ...
Find elsewhere
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-gui
Working with GUI applications in VS Code
November 3, 2021 - How to develop Java GUI Applications (JavaFX, AWT, Swing) in Visual Studio Code
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-tutorial
Getting Started with Java in VS Code
November 3, 2021 - This tutorial shows you how to write and run Hello World program in Java with Visual Studio Code.
๐ŸŒ
YouTube
youtube.com โ€บ kenny yip coding
How to set up Java in Visual Studio Code - YouTube
How to install Java with Visual Studio Code (vscode) in under 5 minutes.Install Visual Studio Code: https://code.visualstudio.com/Install Java Coding Pack: h...
Published ย  May 29, 2023
Views ย  572K
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-linting
Java formatting and linting
November 3, 2021 - Formatting, linting, and code analysis for Java in Visual Studio Code
๐ŸŒ
Medium
medium.com โ€บ @brunoborges โ€บ visual-studio-code-for-java-the-ultimate-guide-2019-8de7d2b59902
Visual Studio Code for Java: The Ultimate Guide 2019 | by Bruno Borges | Medium
June 29, 2020 - Here's the ultimate guide of 2019 for Java developers to use Visual Studio Code to develop, run, debug, and deploy their applications.
Top answer
1 of 9
32

VS Code does not have built-in support for Java projects. You need to install specific Java extensions and configure them to specify the correct Java JDK version. Depending on the extension, you can specify the version by either setting the JAVA_HOME environment variable or by setting the java.home setting:

After installing the JDK, you would need to configure your environment for Java development. The most common way is to set JAVA_HOME environment variable to the install location of the JDK while you can also use java.home setting in Visual Studio Code settings (workspace or user settings) to configure it just for the editor.

I described the installation/setup steps in more detail below. It is mostly based on the Visual Studio Code tutorial for Java. Since the OP commented that they are using macOS, this answer is focused on the Java extension for VS Code on Mac. Also, note that depending on the version of the JDK you have installed, java.home might already be deprecated or has been completely removed, and java.jdt.ls.java.home should be used instead (source). So, replace accordingly. Lekia's comment provides a tip:

you can find java properties including java.home from terminal java -XshowSettings:properties -version


MacOS

First, you need to install the Microsoft Java Extension Pack.

Upon installation, it will display the Java Overview tab, and automatically check for available Java SDKs. If it cannot find one, it will prompt you to download one. (The Java Overview and this JDK Required page seems to also auto-appear when you open/create a .java file).

From the VS Code documentation, these JDK distributions should be supported: OpenJDK, Java SE from Oracle, Azul Zulu Enterprise. For this answer, I am using OpenJDK 11. Download and install the appropriate JDK.

Next, get the path to your JDK. Open a Terminal and then:

$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

If you already have a JAVA_HOME env var set, I recommend not relying on it. I find that it is better to set the relevant java.* properties instead to configure Java specifically for VS Code (or for a particular workspace).

Now, open the VS Code Settings tab and look for the Java: Home setting:

You can modify either the User or Workspace setting. In the screenshot above, I am modifying my User settings, making the java.home/java.jdt.ls.java.home setting affect all Java projects. You can also modify the Workspace setting to configure java.home differently for each workspace.

Click on the Edit in settings.json, and add java.home (you'll know your extension was installed properly if java.* autocompletion is displayed).

Specify the path to the JDK you got earlier:

"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home",

Then restart VS Code. When the Java Overview tab displays again, if you set the path correctly, it should not prompt you anymore to download a JDK, meaning it found your JDK. Try running a very basic HelloWorld.java application.

Windows

If you are on Windows, they provide a special installer to help you get started:

To help you get started quickly, we created a special Installer of Visual Studio Code for Java developers.

Download Visual Studio Code Java Pack Installer

Note: The installer is currently only available for Windows. For other OS, please install those components (JDK, VS Code and Java extensions) individually. We're working on the macOS version, please stay tuned.

2 of 9
8

Add to .vscode/settings.json:

{
    "java.jdt.ls.java.home": "<location-of-your-preferred-jdk>"
}

Note: This is only for the current project.

๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-spring-boot
Spring Boot in Visual Studio Code
November 3, 2021 - Spring Boot extensions for Java developer using Visual Studio Code editor.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-webapp
Java Web Apps with Visual Studio Code
November 3, 2021 - This tutorial shows you how to create a Java web application with Visual Studio Code.
๐ŸŒ
GitHub
github.com โ€บ microsoft โ€บ vscode-java-debug
GitHub - microsoft/vscode-java-debug: Java Debugger for Visual Studio Code.
A lightweight Java Debugger based on Java Debug Server which extends the Language Support for Java by Red Hat. It allows users to debug Java code using Visual Studio Code (VS Code).
Starred by 571 users
Forked by 406 users
Languages ย  TypeScript 94.4% | JavaScript 4.0%
๐ŸŒ
YouTube
youtube.com โ€บ watch
Run Java program in Visual Studio Code | VsCode extension ...
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ java โ€บ java-testing
Testing Java with Visual Studio Code
November 3, 2021 - Testing Java in Visual Studio Code is enabled by the Test Runner for Java extension.