I'm trying to use visual studio code for Java.
Have installed the extensions for Java, and have a 1.8 JDK installed with environment variable pointing to the install.
When starting debugger with a simple hello world program, I get the following:
java.lang.UnsupportedClassVersionError: HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) ...... ...... at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Any help with getting Java debugging in Visual Studio code appreciated.
To change that, go to Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler, and change Project bytecode version to 8.
UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime. How can i make above change? Project -> Properties -> Java Compiler Enable project specific settings. Then select Compiler Compliance Level to 1.7, 1.6 or 1.5, build and test your app.
In Java, we can use javap -verbose className to print out the Java class file information; the output includes the major version number. Or we can use the javap -verbose JavaClassName | grep major to display only the major version of the Java class file.
You are probably compiling (or using dependencies compiled) with java 9, but still using JDK 8.0
Install java 9 and change your OS environment settings to point to the new JDK. This should solve your problem.
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