question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSCode extension JDK version

See original GitHub issue

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: https://github.com/microsoft/vscode-spring-boot-dashboard/issues/125

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:26 (15 by maintainers)

github_iconTop GitHub Comments

3reactions
martinlippertcommented, Mar 19, 2021

So to quickly fix this, change the settings via "spring-boot.ls.java.home" to point to a JDK >= 11.

1reaction
martinlippertcommented, Mar 30, 2021

@rubensa I very much agree that a “wider approach” makes sense here and that it would be good to unify the way the different extensions select and use the JDKs on the system. It would be good to find a common ground here to make this easier for the user.

When looking at this at the broader scope, I think we have two fundamentally different use cases here:

  • (1) the extension itself requires a JDK to run on. The extension usually requires a specific minimum JDK level to run on, due to the extension itself being written in Java and compiled based on a specific minimum Java version.
  • (2) user projects are configured for a specific Java version to compile against and probably can use the same but also a different JDK to run/debug the project.

Both cases are completely separate from each other and should not be mixed up, I think. Different projects might require different JDKs to compile/run against (even in the same workspace different projects might use different JDKs at the same time). Different extensions might need different JDKs as well to work with (e.g. the RedHat Java extension might use JDK14 in the future, whereas the Spring Boot extension still uses JDK11). So it is hard to come up with some unique setting the user defines (like java.home points to a JDK and we use that for everything). But it is also cumbersome for the user to define the individual JDKs all across the place using different settings and options. That is crazy.

One approach could be: We could come up with a unified way to let users define all the JDKs that are installed on their system (or whatever subset they would like to use). Maybe in some way like the RedHat Java extension defines the project JDKs: https://github.com/redhat-developer/vscode-java#project-jdks - but not specifically for projects, but as a general setting of configured JDKs to use.

Then, extensions could ask this unified list for a specific JDK (or a compatible one). So instead of searching for a JDK11 on its own, the Spring Boot language server could ask this unified component for a JDK >= 11 and that unified component would whatever Is configured in that list. In case extensions need to compile/run projects from the user, the extension could also lookup the available JDKs from that list and use them to compile/run against (or let the user even select which JDK to use then running an app).

@Eskibear What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started with Java in VS Code
Java tutorial showing basic Java language support in the Visual Studio Code editor. ... The Extension Pack for Java supports Java version 1.5...
Read more >
About Upgrading to Java 11 for VS Code for Java
How to upgrade · 1. Download and install a Java 11 JDK, if haven't. · 2. Open VS Code and open File> Preferences...
Read more >
How to find and change Java compiler option in Visual Studio ...
First, you need to install the Microsoft Java Extension Pack. ... In visual studio code, you need to change your compliance version in...
Read more >
Setup VS Code for Java development - Rob O'Leary
Since the release of version 1.8 of the Language Support for Java by Red Hat extension (June 30th, 2022), you need to install...
Read more >
JDK Requirements · redhat-developer/vscode-java Wiki - GitHub
Universal Version. For some other extension marketplaces (e.g. Open VSX), they haven't supported platform specific versions yet and will still ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found