Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Runtime only recognizes class file versions up to 52.0 even when java 11 is installed

I can't run my java servelet on my tomcat 9.0.12 server because it can't handle the class version. I get following error:

Error: MyClass 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 (unable to load class

I compiled my code with java 11:


<plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>

when I type in : java -version in my terminal I get:

java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

and for javac -version

javac 11.0.2

Why can't the Runtime handle v55.0? java 11 == v55.0?!

like image 581
el-amigo_loco Avatar asked Sep 03 '26 03:09

el-amigo_loco


2 Answers

Check the version of Java it is showing in the error

  • 45 = Java 1.1
  • 46 = Java 1.2
  • 47 = Java 1.3
  • 48 = Java 1.4
  • 49 = Java 5
  • 50 = Java 6
  • 51 = Java 7
  • 52 = Java 8
  • 53 = Java 9
  • 54 = Java 10
  • 55 = Java 11
  • 56 = Java 12
  • 57 = Java 13

install/download that jdk in program files/java folder

in eclipse or STS right click on project -> builPath -> libraries -> add JRE system libraries -> add the version of jdk showing in the error as an alternate JRE

enter image description here

like image 79
AnushaSP07 Avatar answered Sep 05 '26 16:09

AnushaSP07


The problem is not tomcat but the JVM which runs tomcat.

I don't know how you start tomcat, but you should start it with a JDK 11.

If you use eclipse you should check the Server Runtime.

For other IDEs or starting it from OS directly (as an application or a service or whatever), you should check the JAVA_HOME and the PATH.

like image 23
minus Avatar answered Sep 05 '26 17:09

minus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!