Tomcat Issue: Unsupported major.minor version 52.0
java.lang.UnsupportedClassVersionError happens because of a higher
JDK during compile time and lower JDK during runtime.If you are using eclipse do the following go to menu command Window -> Preferences -> Java -> Compiler and then set "Compiler compliance level" to 1.8
- Make sure JRE_HOME is set to 1.8
0xtimur
Updated on December 20, 2020Comments
-
0xtimur over 3 years
I am a newbie, so you might have to simplify explanation for me. On my command line it says tomcat started. But when I try to go to my browser and type
'Http://localhost:8080'
it says failed to open page.In the Tomcat log I got this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
FYI
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
I have download the latest tomcat version. I am using NetBeans
I have two netbeans one was standard edition that I added the EE plugin (don't know if this has any relevance), the other netbean is download as the EE. Why because I don't know what I am doing and mac doesn't allow me to delete and I don't want to use the command line to this because again I don't know what I am doing.
I have been spending a lot of time on this and I am assuming it has something to do with either JAVA_HOME or the version of the JDK. If that is the case please I need instruction on how to do this. I have been trying to instal maven and tomcat for 2 days now.
**This might help also when I try to run a project on netbeans it says:
NetBeans: No suitable Deployment Server is defined for the project or globally.
Things I have don't but don't know why: Inside my catalina.sh I have written this:
#!/bin/sh JAVA_HOME=/usr/local/apache-tomcat-9.0.0.M1/bin
On my command line LASTLY I have written this:
timurs-MacBook-Air:~ timur$ export PATH=$JAVA_HOME/bin:$PATH
This is tomcat Version info:
timurs-MacBook-Air:~ timur$ /usr/local/apache-tomcat-9.0.0.M1/bin/catalina.sh version Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.0.M1 Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.0.M1 Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.0.M1/temp Using JRE_HOME: /Library/Java/Home Using CLASSPATH: /usr/local/apache-tomcat- 9.0.0.M1/bin/bootstrap.jar:/usr/local/apache -tomcat-9.0.0.M1/bin/tomcat-juli.jar
-
0xtimur over 8 yearsIm using NetBeans, any solution for netbeans?
-
nofomopls over 8 yearsRight click on your project --> Project Properties Then in Sources set Source/Binary Format to JDK 1.8
-
0xtimur over 8 yearsWas already set the JDK 1.8
-
0xtimur over 8 yearsHow do I check if JRE_HOME is set to 1.8?
-
Olaf Kock over 8 yearsWhatever Netbeans uses to start Tomcat (if you're starting out of Netbeans): It's configured to be Java 7. Look at stackoverflow.com/questions/10382929 to see the major version number: If Tomcat complains about unsupported version 52, it stumbles upon code compiled for Java8 while running on Java7 itself.
-
0xtimur over 8 yearsI have already been there before but I don't understand exactly what they are saying or not how to implement it
-
nofomopls over 8 yearsMaybe your tomcat version could run with java 1.7 compiled source, so you should try with java 1.7 in netbean and rebuild your app
-
Ritesh Karwa over 8 years@TimurOzkul whta do you get when you do echo $JAVA_HOME and echo $JAVA_JRE
-
0xtimur over 8 years$JAVA_HOME i get /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk for the $JAVA_JRE nothing
-
0xtimur over 8 yearsIs it suppose to be set to the samething?