vscode-java: JAVA_HOME is not pointing to a JDK.
[provide a description of the issue]
Environment
-
Operating System: macOS Mojave
-
JDK version: OpenJDK 11.4
-
Visual Studio Code version: 1.38.1
-
Java extension version: 0.48.0
Steps To Reproduce
- Opening Java Project
Current Result
After opening a Java project, the configure window pops up and shows, that the JAVA_HOME
is set, but it’s not pointing to a JDK.
The JAVA_HOME
path is correctly set.
Expected Result
JDK should be found.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 30 (7 by maintainers)
I had the same problem on my Mint. The problem was fixed after I reinstalled openjdk-11. I used the following command. Should work for Ubuntu as well.
sudo apt install openjdk-11-*
Got the same error on Linux Debian 10.5 (buster). I realized that if I was launching VSC by the application itself, it was doing this error, while if I launch VSC through the terminal, all’s good. Maybe user’s settings.
Let me help to form a guide from most of above cases.
Root cause
Because of the confusing name of packages, some Linux users actually installed a JRE (Java Runtime Environment) instead of a JDK (Java Development Kit). As
./bin/javac
doesn’t exists under path of Java home folder, the extension recognizes it as a JRE instead of a JDK (which is required), thus prints this error message.Follow below steps to fix it
.bin/javac
exists under above path.openjdk-11-jdk
with an additional jdk appendeddevel
,src
,all
etc.Getting same error on Linux openSUSE,
JAVA_HOME set correctly:
[UPDATE]: It seems what I had install was only the JRE even though it’s named openjdk?
I ended up downloading the package suggested to me by vscode in the, “Configure Java Runtime” setting, point JAVA_HOME to it and everything works, no errors.
You can also down the jdk from here: https://jdk.java.net/
Update A better solution might be to use SDKMAN to install java, jdk and sdk! https://sdkman.io/
I have same issue on Fedora 32. I have set all paths as required but still issues
Not sure why this coninues to be an issue for me. I enjoy using VSC for quick edits where VI* isn’t the only option available. Although with my $JAVA_HOME set, exported automatically, and picked up on automatically by other IDEs such as IntelliJ, Eclipse, AND NetBeans… VSC even shows the path it found, but instead decides to mention that in my settings “$JAVA_HOME” is an invalid path…? wuh wuh?
Advice for a JDK8 user?
@phhoef I guess you did set the wrong JAVA_HOME, by appending an extra whitespace.
From the bottom-left error box in your screenshot, you can see there is a whitespace before
)
, and check the source code, it must be from your JAVA_HOME.Back to compare the original screenshots, you can see more clear that your JAVA_HOME was longer than mine, with an extra whitespace.

try
"java.home": "/home/agilob/.sdkman/candidates/java/14.0.1.hs-adpt"
there’s no 14.0.1-open in your candidates directory.FYI, I’ve just tried the latest AdoptOpenJDK 11, and it works well for me.
A JDK(instead of JRE) is required. Please check
bin/javac
exists under JAVA_HOME? e.g. using commandls $JAVA_HOME/bin/javac
.