Repository navigation
Closed
Labels
Description
Installed version
- Spring Boot Extension Pack v0.0.8
- Spring Boot Dashboard v0.2.0
- Spring Boot Tools v1.25.0
- Spring Initializr Java Support v0.7.0
Looks like some code in the latest version is compiled against Java 11 (but prerequisites is JDK 8)
Activating 'vscode-spring-boot' extension
Found java exe: /opt/sdkman/candidates/java/8.0.282.hs-adpt/bin/java
isJavaEightOrHigher => true
Redirecting server logs to /dev/null
ERR: Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/ide/vscode/boot/app/BootLanguagServerBootApp has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
Also reported here: spring-projects/spring-tools#612
Activity
rubensa commentedon Mar 22, 2021
Following discussion from spring-projects/spring-tools#612
The JDK pointed by 'java.home' is used to launch the Java Language Server from RedHat extension. It is also used by default to compile your project but if you provide 'java.configuration.runtimes' pointing to multiple JDKs then the "best match" based on your project configuration (Eclipse .settings/org.eclipse.jdt.core.prefs or .classpath settings, maven pom.xml settings or Gradle build.gradle settings) is used.
This is all about "compilling"... the problem is that I don't know how STS4 uses the RedHat extension to launch the application. I'm starting to think that the JDK used to launch is the same as the Java Language Server is running on (that is JDK11 as a minimun) and not the one used to compile (chosen based on settings "best match").
Can anyone clarify this?
Eskibear commentedon Mar 23, 2021
The JDK used to compile and run your project should be the same, controlled by 'java.configuration.runtimes' (if specified). See redhat-developer/vscode-java#1543 (comment)
About these extensions and language servers
Redhat extension contains a Java Language Server, which requires JDK 11+ to launch itself, and as you mentioned can be set by 'java.home'.
AFAIK, STS4 has two components:
rubensa commentedon Mar 23, 2021
Thanks Yan Zhang (@Eskibear) for your comment.
As there is some "kind of magic" in the "best match" selection among the available runtimes (controlled by 'java.configuration.runtimes') I found there is a related open issue: feature request: select java runtime in vs code settings
Eskibear commentedon Sep 17, 2026
Closing as completed. spring-projects/spring-tools#612 shipped JDK validation, and the original JDK 8 scenario is obsolete.