vscode-java: Openjdk is being treated as invalid JDK on vscode for linux
Issue Type: Bug
The following error is received on Configure Java Runtime Extension Page of the Language Support for Java Extension:
This path is not pointing to a JDK.
But java commands are working alright in the terminal.
echo $JAVA_HOME
gives /usr/share/java/jdk-11.0.4
and java --version
produces this output:
openjdk 11.0.4 2019-07-16 OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04) OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)
Extension version: 0.50.0 VS Code version: Code 1.39.1 OS version: Linux x64 5.0.0-31-generic snap
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 21
- Comments: 29 (3 by maintainers)
Hi @tarun0,
I had a similar issue on Ubuntu 19.10. Installing
openjdk-11-jdk
explicitly fixed it. The directory/usr/lib/jvm/java-11-openjdk-amd64/
contained a jre before installing the jdk.Gabor
Same issue. OS: Ubuntu 18.04.3 LTS
ls -la /usr/lib/jvm/java-11-openjdk-amd64
gives following output (after changing the owner to tarun from root but even that didn’t solve)Below is the complete error (doesn’t point to jdk)
On Fedora 32, I finally got it working by installing
java-11-openjdk
java-11-openjdk-devel
and setting this configuration in vscode:WOOOOOOOOOOOO!
Found the answer here.
https://github.com/redhat-developer/vscode-java/issues/108
For OSX, use:
I fixed it by installing openjdk-11-jdk-devel package.
On archlinux and manjaro,
/usr/lib/jvm/default
is symlinked to the default JDK version. However, the extension doesn’t seem to recognize/follow the symlink, and you have to explicitly point it to a specific version/usr/lib/jvm/java-14-openjdk
.@Katona’s solution worked for me (thank you) 🥳
Here’s the following for Archlinux (via package manager) 👇
jdk
:$ pacman -S jdk-openjdk
(or whichever version you wish)settings.json
):Here is my settings.json { “java.configuration.updateBuildConfiguration”: “interactive”, “java.home”: “/usr/share/java/jdk-11.0.4”, “java.completion.enabled”: true }
For anyone working in the updated vscode where the new setting is
java.jdt.ls.java.home
instead ofjava.home
, I managed to solve the issue by realizing there are two locations where it defines java home (user and workspace) and they were set to different things. I changed them to the same path and it seems to have worked.I solved it by Downloading AdoptJDK and specifying the path of the downloading JDK in
java.home
in settings.@piyushkrmaurya did you install vscode via flatpak? If that’s the case then you should look into https://github.com/redhat-developer/vscode-java/issues/510#issuecomment-462567417