Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"
Today Visual Studio Code started showing me a pop-up saying:
Java 11 or more recent is required to run. Please download and install a recent JDK.
I need to use the JDK 8 (working on Apache Beam and that's the last supported version). I have been working on that and haven't had any issues until this came up.
I have read through this article and implemented the points mentioned there.
Here is my workspace settings on Visual Studio Code (I have double-checked the paths)
{
"java.configuration.updateBuildConfiguration": "disabled",
"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
"default": true
},
{
"name": "JavaSE-11",
"path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home",
}
]
}
Other helpful information:
➜ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
and
➜ which java
/usr/bin/java
This started happening today even though I have been running JDK 8 on Visual Studio Code successfully for a while now. I don't remember updating Visual Studio Code, so I'm not sure as to why this is being displayed now since apparently the pop-up has been displayed since mid-April (asked on the vscode-java Gitter channel).
Solution 1:
Change from
"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"
to
"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home"
and keep the rest of the settings as is.
Solution 2:
For future readers. If you are using the extension "Spring Boot Tools" you may get a similar error to this. I had my JAVA_HOME set to java 8 but required java 11 to use the Spring Boot Tools Language Server. It seems that Spring Boot Tools uses whatever your JAVA_HOME environment variable is or in the PATH environment variable, Spring Project Issue. To override your JAVA_HOME variable you'll need to modify the spring-boot.ls.java.home
setting.
- Open Visual Studio Code
-
CRTL + ,
to open the settings - Search
spring-boot.ls.java.home
- Select 'Edit in settings.json'
- Your Java 11 installation →
"spring-boot.ls.java.home": "C:\\Program Files\\Java\\jdk-11.0.10"
- Save and restart VS Code
Prereq: Have a Java 11 installation