Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(class file version 53.0), Java Runtime versions up to 52.0 Visual studio code [duplicate]

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.

like image 268
Dave Jones Avatar asked Nov 03 '17 18:11

Dave Jones


People also ask

How do you fix has been compiled by a more recent version of the Java Runtime?

To change that, go to Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler, and change Project bytecode version to 8.

How do I fix Java Lang UnsupportedClassVersionError in Java?

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.

How do I find the Java Runtime class version?

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.


Video Answer


1 Answers

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.

like image 77
Roeland Van Heddegem Avatar answered Sep 21 '22 21:09

Roeland Van Heddegem