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
In the build.gradle file of an existing Gradle project, add the following:
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
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)

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.
cc: @naco-siren
@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:
JAVA_HOME to now point to my JDK 12 installation.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!
Most helpful comment
Hey! Thanks @fbricon :+1:
F1 | Java: Java Force Compilation | Fulldid the trick. I also had to do aJava: Clean the Java language server workspacebecause 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.