How to find and change Java compiler option in Visual Studio Code?

setting jdk in visual studio code
visual studio code java
visual studio code selenium java
create java project in visual studio code
how to add jar file in visual studio code
visual studio 2019 java
vscode-java formatter
visual studio code formatting settings

I am new to Visual Studio Code (VSC) and I come from Eclipse. VSC tells me 2 errors on my project:

  • Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.

  • The compiler compliance specified is 1.5 but a JRE 1.8 is used.

Same as in Eclipse, I am looking for a preferences window to change the level of Java compiler (from 1.5 to 1.8 in my case) but I can't find it. I can only see files everywhere. The menu Preferences show many settings but nothing for the Java compiler.

VS Code does not have built-in support for Java projects. You need to install some Java extensions and configure them to specify the correct Java JDK version, which you can do 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 below. It is mainly based on the Visual Studio Code tutorial for Java. Based on the OP's comment, I'll focus on setting-up the Java extension for VSCode on Mac.


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. 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

If you already have JAVA_HOME set (echo $JAVA_HOME), I recommend unsetting it. I find that it is better to use the java.home setting 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 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 application.


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.

Navigate and edit Java Source Code in Visual Studio Code, Once you open your Java project or any source files with VS Code, all code navigation features as well as syntax check and documentation (hover to see� Running and debugging Java. Visual Studio Code allows you to debug Java applications through the Debugger for Java extension. It's a lightweight Java debugger based on Java Debug Server, which extends the Language Support for Java by Red Hat.

Java in Visual Studio Code, Tutorial � Compiling � Debugging Leveraging the power of Visual Studio Code, Java developers get an excellent tool for both To help set up Java on VS Code, there is a Java Extension Pack, which contains the most will cause those extensions to understand those artifacts and present options for working with them. The tsconfig.json file lets you control how Visual Studio Code compiles your TypeScript code. For more information, see the tsconfig.json overview . Why do I get different errors and warnings with VS Code than when I compile my TypeScript project?

Using all your answers, I realized that the error was on a project made of Javascript Angular, no need of Java. Then I deleted the directory ".settings" and file ".classpath".. and these 2 errors disappear.

Thank to all.

Java with Visual Studio code (Vscode) Part 1, Figure 1.2 Search For Java Home Configuration of Visual Studio Code. In “1” After “User Settings” JSON file open, Then You will search for “Java. home” in search option. In “2” Click on “Edit in Setting.json” link. Figure 2.2, Add the Application Class And How Visual Studio Code added the Compiler Configuration to Java Application In Figure 2.2, I have create sample class named and add main

Edit: My pom.xml file was not correct. If you use Maven, take a other look on that file.

For me, it was in the ".settings" folder (it should be in your Java project). There's some "org.eclipse" files in there. You just need to change the 1.5 to 1.8.

redhat-developer/vscode-java: Java Language Support for , Java Language Support for Visual Studio Code. the java.home setting in VS Code settings (workspace then user settings); the JDK_HOME environment� I actually wrote this article because I had a C++ assignment which required using a compiler. As usual, everyone was using the CodeBlocks IDE and Visual Studio IDE. But I was already used to Visual Studio Code for all my programming stuff. I then set out to find a way of compiling C++ directly inside my own VsCode Editor, hence this article :).

Option to specify Java path ? � Issue #28 � redhat-developer/vscode , How about an option to specify Java directory (JAVA_HOME already points to Java 7) ? However, VS Code needs to be restarted after setting the value. to 8 to get the extension working, but my code doesn't compile. If you are targeting Windows, the Microsoft C++ compiler (MSVC) may be the way to go. This is the default compiler for most Visual Studio C++ projects and is recommended if you are targeting Windows. Compiler options for the Microsoft C++ compiler. Clang. You can use the Clang compiler with Visual Studio to target Android, iOS, and Windows.

Visual Studio Code for Java: The Ultimate Guide 2019, Visual Studio Code has come a long way to become the preferred text editor of There is a set of extensions that are the minimum requirement to get core type ⌘+` — and then type javac to compile the file. Specify symbol (.pdb) and source files in the Visual Studio debugger; C++ compiler and linker options. C++ compiler and linker options are located under the C/C++ and Linker nodes in the left pane under Configuration Properties. These translate directly to command-line options that will be passed to the compiler.

Setting up the Java Development Kit for Visual Studio, Setting up the Java Development Kit for Visual Studio. The Elements compiler requires the Java SDK 7 or later to be installed if you want to build Java apps. After Java is installed, Elements should detect it automatically. If it does not, you can manually configure the JRE and JDK paths in the "Tools|Options" Dialog:� How to run java program in visual studio code, Build task for java in visual studio code, Java compile and run in visual studio code. Tasks.json

  • Visual Studio Code does not have built-in Java support like Eclipse does. If you are looking for features specific to any language they will be provided by extensions. Are you already using an extension for Java? Have you looked at the documentation/readme for that extension?
  • This link has helpful information.
  • What is your OS?
  • Thank for your help. I am on MacOS with Microsoft java Extension pack...
  • Using all your answers, I realized that the error was on a project made of Javascript Angular, no need of Java. Then I deleted the directory ".settings" and file ".classpath".. and these 2 errors disappear.
  • I am on MacOS. I tried to add the java.home in settings.json .. and restart VSC . no change. (how to add the snapshot here in comments?).
  • I updated my answer to provide a more detailed step-by-step description for setting-up the Java extension and java.home. Check that the path you set is correct.
  • Thanks for your answer. I found the file you said, I changed it to 1.8, restarted VSC but problem still here. I don't know if my changes are taken into account (is restart sufficient ? or shall I send any command ?)
  • Shall i know? whether you have built project with maven or used regular java project