Vscode-java: „Unbound classpath container: 'JRE System Library [JavaSE-11]' in project“ With JDK 12 Installed

Created on 21 Apr 2019  Â·  5Comments  Â·  Source: redhat-developer/vscode-java

VS Code reports classpath problems if a Gradle build script specifies source and target versions that are different from the Java version that's installed:

x Unbound classpath container: 'JRE System Library [JavaSE-11]' in project 'jarexec.plugin'
x The project cannot be built until build path errors are resolved
Environment
  • Operating System: Linux x64 4.15.0-47-generic snap
  • JDK version: OpenJDK 64-Bit Server VM (build 12-ea+15, mixed mode, sharing)
  • Visual Studio Code version: 1.33.1
  • Java extension version: 0.43.0
Steps To Reproduce
  1. Install JDK 12
  2. In the build.gradle file of an existing Gradle project, add the following:

    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11

  3. Launch VS Code from inside the directory of the existing Gradle project

[attach a sample project reproducing the error]
[attach logs](https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#enable-logging)

Current Result

lingocoder vscode unbound classpath container 0 a

Expected Result

0 Problems. Java does not require there to be an installed version of that specified in the source and target options. Java allows you to specify source and target versions that are lower than that of the installed version of Java that will be used to compile the target code.

Additional Informations

cc: @naco-siren

Most helpful comment

Hey! Thanks @fbricon :+1:

F1 | Java: Java Force Compilation | Full did the trick. I also had to do a Java: Clean the Java language server workspace because compilation didn't seem to take for some reason. Mind you, I am on a super slow, low memory VM at the moment. So that's gotta be giving vscode some trouble.

Cheers.

All 5 comments

@lingocoder What kind of java app? How about version 12?

It is a Gradle plugin, @yaohaizh .

UPDATE

After a good night's sleep I remembered that I had JAVA_HOME in settings.json pointing to a JDK 8 installation I'd forgotten about. I:

  1. changed JAVA_HOME to now point to my JDK 12 installation.
  2. edited ./settings/org.eclipse.jdt.dore.prefs to:

    org.eclipse.jdt.core.compiler.compliance=12
    org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
    org.eclipse.jdt.core.compiler.source=11
    org.eclipse.jdt.core.compiler.release=enabled
    org.eclipse.jdt.core.incompatibleJDKLevel=ignore

Now the Problems pane no longer reports the original error. Instead, it now reports this warning:

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

NB — If I remove the sourceCompatibility and targetCompatibility from build.gradle, the warning goes away. More importantly, the issue that the warning points out should not matter under the circumstances of my project's requirements. Meaning: removing those from build.gradle is not an option. I just want the warnings to go away. They're annoying.

Oddly enough, this particular setting doesn't go into ./settings/org.eclipse.jdt.core.prefs but ./settings/org.eclipse.jdt.launching.prefs:

eclipse.preferences.version=1
org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=ignore
org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore

You'll need to execute a full build for the compiler to apply the new settings: (Java force compilation>Full command)

Hey! Thanks @fbricon :+1:

F1 | Java: Java Force Compilation | Full did the trick. I also had to do a Java: Clean the Java language server workspace because compilation didn't seem to take for some reason. Mind you, I am on a super slow, low memory VM at the moment. So that's gotta be giving vscode some trouble.

Cheers.

@fbricon Your workaround seems to be the only post about this issue. Thank you!

Was this page helpful?
0 / 5 - 0 ratings