I'm having issues with setting up the JREs in my VSCode workspace. I thought the issue was correctly setting up my java.home
in my settings.json
but I'm still getting this error:
Build path specifies execution environment JavaSE-10. There are no JREs installed in the workspace that are strictly compatible.
I've looked at the answer here (Warning - Build path specifies execution environment J2SE-1.4) but the solution is for Eclipse and not VSCode.
I think it is because the JRE is specifying Java10 and I'm using Java11.
Any suggestions on how to set up the JRE for VSCode?
Also, here is the java version I'm using and my settings.
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
11.0.1, x86_64: "Java SE 11.0.1" /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
And my java.home
settings in VSCode:
"java.home": "/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home"
Procedure. In Eclipse select the web project and right-click Build Path > Configure Build Path. This will display the Java Build Path window. Add the CICS and Liberty libraries, click Add Library > CICS Liberty libraries > Next > Finish.
To totally remove the warnings/errors, I believe you need to:
JavaSE-10
" as the name
in the java.configuration.runtimes
array in your settings.json
Given the question was posed in 2018, for my current version of VS Code (1.49.2), it will use a higher JDK version in "compatibility" mode and similar messages are just warnings.
As I had some difficulty myself figuring out and configuring everything, and this still ranks high on Google searches, I am documenting the full instructions for setting the java.configuration.runtimes
(particularly in regards to Windows and WSL), since it is preferable for me to not change the entire default JDK using the java.home
setting (particularly since this might break JSL also if using JDK versions < 11, as explained below).
According to:
https://code.visualstudio.com/docs/java/java-project#_configure-jdk:
https://github.com/redhat-developer/vscode-java#setting-the-jdk
java.home
setting should be used to point to the JDK used by the JLS, and also code compilation if not explicitly overriddenjava.home
setting in VS Code settings (workspace then user settings)JDK_HOME
environment variableJAVA_HOME
environment variablejava.configuration.runtimes
in the respective settings.json
(i.e. workspace and/or user):
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "/path/to/jdk-8",
},
{
"name": "JavaSE-11",
"path": "/path/to/jdk-11",
},
{
"name": "JavaSE-14",
"path": "/path/to/jdk-14",
"default": true
},
{
"name": "JavaSE-15",
"path": "/path/to/jdk-15",
"default": true
},
]
default
s, but the example from their own Wiki and the VS marketplace description have only one.To edit the settings.json
to add (or edit) the java.configuration.runtimes
setting/s:
settings.json
you are attempting to edit (i.e. user or specific workspace/s) (screenshot showing 3 environments)java.configuration.runtimes
" in the search boxsettings.json
file directly by clicking on the `Open Settings (JSON)' button near the top right of the window
(as per above screenshot)settings.json
and enter your customised java.configuration.runtimes
snippet (as exemplified above), ensuring to use only the allowed "name
"s (as mentioned above) and using the correct paths (taking into account if it is Windows or Linux paths - the latter applicable to WSL)settings.json
edit windowpom.xml
's maven.compiler.source
and maven.compiler.target
, synchronising the project's Java classpath and configuration when prompted (which will also update your Eclipse org.eclipse.jdt.core.prefs
' org.eclipse.jdt.core.compiler.codegen.targetPlatform
, org.eclipse.jdt.core.compiler.compliance
and org.eclipse.jdt.core.compiler.source
accordingly (if it also exists)Example java.configuration.runtimes
snippet from settings.json
:
Windows (JDK 1.8 and 12 installed)
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "C:\\Program Files\\Java\\jdk1.8.0_261"
},
{
"name": "JavaSE-12",
"path": "C:\\Program Files\\Java\\jdk-12.0.1"
}
]
WSL (remote) (JDK 1.8 and 11 installed):
"java.configuration.runtimes": [
{
"name:": "JavaSE-1.11",
"path": "/usr/lib/jvm/java-11-openjdk-amd64"
},
{
"name": "JavaSE-1.8",
"path": "/usr/lib/jvm/java-8-openjdk-amd64"
}
]
In my case, I have setup Maven as the build environment for Java within VSCode. For maven, I found that one of the build properties in pom.xml was set to Java version 1.8, which was older than what I was using, namely 1.11. Once I updated the property as below, the warning disappeared.
<properties>
<java.version>1.11</java.version>
</properties>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With