I just started off with Google App Engine 1.6.4 in Eclipse Indigo a couple of days ago and I face a problem with the back end.
Whenever I try to use a servlet or a JSP, I get this annoying
java.lang.UnsupportedClassVersionError: org/msamogh/MyServlet : Unsupported major.minor version 51.0
I tried changing my JRE to Java 6, but the error still remains. Does anyone know how to fix this.
The major.minor version 51.0 seems to indicate that your classes are compiled using Java 7. Please make sure that the following are done:
Start Eclipse using a Java 6 JDK.
Set the default JVM in Eclipse to a Java 6 JDK.
Set the default and/or project compiler settings to use 1.6 target.
In general, you need to make sure that your runtime JRE is able to understand your compiled code. If you try to run code compiled for 1.7 on a 1.6 JRE, you will get the above error.
What is your output when you do java -version? This will tell you what version the running JVM is.
The Unsupported major.minor version 51.0 error could mean:
app is running on a lower Java version then the one used to compile it
Try adding a SYSTEM VARIABLE that looks like this: JRE_HOME = C:\PROGRAM FILES\JAVA\JRE7 or JRE6 shipped with the JDK 1.7 or later package with which you compiled it.
Related
I have an application that needs to be deployed in JBoss 6.0.0 and I am using Eclipse Mars. My system variable points to Java 1.6, from build path I've selected Java 1.6 and also, JBoss is using Java 1.6. My problem is that when trying to deploy the app to JBoss the following error
[org.jboss.detailed.classloader.ClassLoaderManager] Unexpected error during load of:com.xservice.java.velocity.VelocityLoader: java.lang.UnsupportedClassVersionError: com/xservice/java/velocity/VelocityLoader : Unsupported major.minor version 52.0.
I don't have any idea how to handle this considering the given settings.
The problem was fixed by changing the Java version from Project Facets(it was 1.8 instead of 1.6). Thanks go to Sanjeev Saha.
Project facets screen
Please locate the Jar which contains the class com.xservice.java.velocity.VelocityLoader.
This class is compiled with JDK 8. The class file version for Java SE 8 is 52.0 as per http://www.oracle.com/technetwork/java/javase/8-compatibility-guide-2156366.html Your JVM is Java 6. You may not be able to run a Java class compiled with JDK 8.0 by JVM 6.0. This is the reason you are getting 'Unsupported major.minor version 52.0'
My suggestion is using a Jar which contains classes compiled by JDK 6.0.
While running the code it shows a alert
Errors occurred during the build
Errors running builder 'Android Package Builder'
on project 'Test'.com/android/dx/command/dexer/Main :
Unsupported major.minor version 52.0
Eclipse was running properly but after the updation of eclipse it shows the error.previously it was running well,i.e before updation
help me solve this issue and run my project.
also help me with some update-able adt bundle.
I have got the same exact issue, but not the same solution solved it :
To fix this, i have to go in my project.properties file :
And in this file add this line :
sdk.buildtools=23.0.3
your code might has been compiled with Java Higher version(i.e. 8), while you are trying to run it with Java Lower version(i.e. 7). Note that Eclipse has it's own compiler and does not use the one from the JDK and most probably it is configured to use Java Higher version(i.e. 8). Check you eclipse compiler preferences.
Solved the issue , Previously I compiled with jAVA 1.7 and run in jdk 1.8 that was the reason of my issue now i download JAVA 1.8 now it is running
J2SE 8=52,
J2SE 7=51,
J2SE 6.0=50,
J2SE 5.0=49,
JDK 1.4=48,
JDK 1.3=47,
JDK 1.2=46
JDK 1.1=45
The only one reason for Unsupported major.minor version 52.0 in eclipse is API Level 24
So please do following things to resolve Issue in Eclipse :
GO To Window menu
2.Open Android SDK manager
3.Check is API level 24 is installed any Platform
4.If YES Please Uninstall this API level 24 Packages.
5.Clean Project and Run Again.
And its Work fine.
Adding the below line in project.properties and setting Java to 1.7 solved the issue to me.
sdk.buildtools=23.0.3
When my jar is run on another computer there occurs a java exception but on my setup it runs ok. They are using Java 1.8? atleast one of them is. and my JDK is also 1.8.
Could the cause of this be in META-INF? I also tried sending .class files and running the main class using cmd (it maybe gave some other error i think)
Also I've exported it as a jar from eclipse, not executable jar. Could this be the cause?
EDIT
One of the stacktraces says: "Unsupported major.minor version 52.0"
Java version mismatch. The other computer not really running with JRE 8.
See this answer for detail Unsupported major.minor version 52.0
Your code was compiled with Java Version 1.8 while it is being executed with Java Version 1.7 or below.
I am trying to deploy my JSP and java files on the server. But when I try to access the jsp I get the error msg
javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: com/usct/db/DBConnect : Unsupported major.minor version 51.0
I read a few posts and found out that this is due to difference in Java version on the two different platforms but I am using JAVA 1.7 on my server and my client when I do
java -version
in my jdk/bin it shows that the java version is 1.7.0_10 and
Java SE Runtime Environment (build 1.7.0_10-b18)
Can someone please help me with this issue?
Thank you
... but I am using JAVA 1.7 on my server and my client when I do ...
The most likely explanation is that you are actually using Java 1.6 or earlier ... despite what you think. In other words, when you run java -version from the command-line, you are getting a different Java installation to the one that is being used to run your web container.
(If you are on a Linux system, you should be able to tell which JVM is being used by running ps -efl and greping for "java" or similar. Alternatively, use the approach suggested by #dbf.)
It is worth noting that the version of Java on the client is not relevant. The exception is occurring on the server side.
Reference: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
- explains the general problem and solution.
java.lang.UnsupportedClassVersionError error occurs due to higher JDK during compile time and lower JDK during runtime.
Java Version Major Version
Java 4 48.0
Java 5 49.0
Java 6 50.0
Java 7 51.0
So if you compile your Java source file with javac of JDK 1.7 it will
create class files with major version 51.0 and if you run those class
files with Java 1.6 it will throw
java.lang.unsupportedclassversionerror unsupported major.minor version
51.0 error
Try Compiling with older JDK or Upgrade the JRE.
More more information visit.
I believe com/usct/db/DBConnect is not a class provided by Java. And hence the reason of your error is not the version of jdk and jre on both your coding and execution environment. It seems the jar you used for the class DBConnect on your client and environment are of different java versions.
Try to print System.getProperty("java.version") from your JSP to check what version is actually used by your server.
I'm trying to run an ant script from eclipse but it fails with the following message:
BUILD FAILED
project_path/build.xml:5:
java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main :
Unsupported major.minor version 51.0
However, when I run this from command line (./ant) it runs as expected.
Environment info:
OS: Linux Mint 64
Eclipse: Juno (4.2.1)
JDK: Oracle 1.7.0_11
Ant (command line): 1.8.2
I've also set the "Ant Home" (within eclipse settings) to be the same as the one I use from command line.
I've searched a lot on this issue but I can't seem to find anything that helped, I can try to uninstall all java (jdk/jre) I currently have installed, and then reinstall java 7, but I prefer not to take this route.
Any ideas?
Thanks!
UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 51.0
This suggests there's some mix up between versions - Ant is trying to run the Java 7 javac on a Java 6 JVM. Have a look at your project properties, builders, Ant Builder, and check the classpath section. On my Eclipse with a newly-created Ant Builder I have the tools.jar from my 1.7 JDK listed under user entries -> additional tasks and support. If you have the same, but your Eclipse is itself running on Java 6 then it won't work. You can find out which Java Eclipse itself is running on via the "about Eclipse" box under installation details -> configuration. This may not be the same as the version of Java that your project is configured to use.
Another thing that might fix it is to go to the JRE tab in the ant builder settings and tell it to run in a separate JRE rather than running within the Eclipse process.
Your Eclipse ant task is trying to run the Java7 JDK compiler using a pre-Java7 JDK/JRE. Make sure you use a Java7 JRE to run Eclipse.
generally if you compile Java program in Java 1.7 it will create class file with major version 51.0 and if you run that on lower java version you will get
java.lang.unsupportedclassversionerror unsupported major.minor version 51.0
check this post for more details on the same