I am stuck on the following error. I don't know what type of error it is. What should I do?
C:\Users\shehzad\Desktop\Software>java -jar Untitled.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: FrontEnd/MainWindow : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Scenario is: I developed software that works fine in Ubuntu 14.04 Lts. It's JAR also works in Ubuntu, but when I tried this JAR
in Windows 7 it shows the above error.
Ubuntu Java version: 1.8.0_101
Windows Java version: 1.7.0_79
class version 52.0 means it requires Java 8 to run. You should for security reasons update your Windows Java anyway, so its time to go to Java 8. If you need Java 7 for something you can keep it as a private installation, but make sure the "javapath" as configured by the registry points to Java 8.
You can also start in a command window or via explorer link the right Java.exe without installing it as public version like this:
"c:\Program Files\java\jdk_1.8.0_102\bin\javaw.exe" -jar app.jar
Your jar file is compiled using 8u101 (major.minor version 52.0) and your trying to run on 7u79. Hence you end up in Unsupported major.minor version 52.0.upgrade your java to 8u101.
Related
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 7 years ago.
The problem might be that at school we probably use a different eclipse version than the one I use at home. We had to make a fraction class and a junit class for it.
java.lang.UnsupportedClassVersionError: FractionTest : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:685)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
picked up _JAVA_OPTIONS: -Xmx512M
That's the error. What should i do to fix this? Also, when i opened eclipse today, and opened the work space, it said something about a newer workspace vesion.
It's happening because of a higher jdk version during compile time than runtime. If you are using eclipse, check window -> preferences -> java -> compiler. What are these set to? They should all be the same.
It seems like you have compiled the source code in one version of jdk and trying to run it on another version of jre. Just recompile the source code where you want to run it. Otherwise install the same version of jre for the jdk which is used for compilation.
Regarding eclipse, from the exception it seems like the code was compiled using Java 8. So install Java 8 and use eclipse luna-r or mars for better comparability.
I've written a code that is supposed to be exporting a set of windows registry keys. I've successfully written the code and was able to also send the results of executing the code as a jar file to my email. However, while testing the jar file ( I've included the piece of code in the build.xml from the java website that will allow me to run the jar file out of the dist folder) I was able to get the desired results on my machine because I wrote the code on a windows 8.1 machine. While testing it on another machine ( with Windows 8 and Windows 7 professional ) I was not able to execute the code and the error I was getting was as follows :
"Java Virtual Machine Launcher, A Java Exception has occurred."
I used to get that error message when I did not include the code in the build.xml page to allow the jar file to run out of the dist folder, but now I'm getting it when I'm executing the jar file on different machines other than my own
Running it from the command prompt this is what i got:
Exception in thread "main" java.lang.UnsupportedClassVersionError: smc_1/SMC_1
W1 : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
#Sara, that error is a JVM mismatch error. I think you're trying to run a jar compiled for Java 8 on a system with Java 7 (or older) installed. Your options are (a) update the JVM to Java 8 or (b) recompile your application with the target set to 1.7 or whatever JVM you need to target, provided that your app doesn't include any Java 8-specific code. Oracle has some information on updating Java to the latest version here: http://www.java.com/en/download/help/java_update.xml
Playing with a little network program, created a Jar with netbeans. Runs just fine on my computer java 1.7.0.60, but when I take it to another computer that has a newer version of java 1.7.0_65 it will not run, I get this error:
C:\Program Files (x86)\Java\jre7\bin>java -jar ReverseEchoServer.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: reverseechose
rver/SocketClient : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
I have read several posts on here that talk about PATH, have looked at that but no luck. I belive its the version differance. Any advice would be most appreciated, Thanks!
Java class files compiled for Java 7 have Major/Minor versions 51/0. If you have a JVM implementation that wasn't prepared for Java 7, it would give you this error indicating "I don't know how to interpret and run this class file."
Try either compiling for an older JVM version, or upgrade your JVM.
Use the Target and specify the version in which it needs to be executed using target switch followed by version number.
javac -target 1.7 yourJarName.jar
I am trying to run a java based java profiler to find out what uses up resources on my java application on my dedicated machine. The profiler I am trying to use is called warmroast.
I get the following error from running.
java -jar warmroast.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
I think this error is caused by running the file with jre instead of jdk.
I have installed java-1.7.0-openjdk-1.7.0.55-2.4.7.1.el6_5.x86 as a yum package.
[root# ~]# java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
I think to fix this problem, I will need to run the jar file using jdk. Is there some kind of a jdk path to the jdk bin file? If so, what is it in centos? I've googled for a while and came up with dozens of wrong paths. I feel stupid because I think jre is a part of jdk and jdk is only using for compiling stuff and I don't think you can run files with jdk...
...
...
The class that could not be found is in tools.jar in your JDK. This library is usually not automatically on the class path, even if you use JDK instead of JRE.
According to the documentation, on Linux warmroast should be started as follows (replace PATH_TO_JDK with the path to your JDK):
java -Djava.library.path=PATH_TO_JDK/jre/bin -cp PATH_TO_JDK/lib/tools.jar:warmroast-1.0.0-SNAPSHOT.jar com.sk89q.warmroast.WarmRoast --thread "Server thread"
Here, tools.jar is manually added to the classpath.
Basically what I want to do is create a PDF from a iReport jrxml or jasper file.
The idea is to use this for reports over the net and the best solution I managed to find was to use a program like jasperstarter and then run the report with a connection to MSSQL database.
To get the connection going I had to download the latest net.sourceforge.jtds.jdbc.Driver.
The report works fine using iReport 5.1 but when I do follow the instructions from jasperstarter I get an "java.lang.UnsupportedClassVersionError" response.
jasperstarter command
jasperstarter pr -t generic -f pdf -i test_report.jasper -o test -u username -p password --db-driver net.sourceforge.jtds.jdbc.Driver --db-url jdbc:jtds:sqlserver://LOCAL-PC/Demo_DB
output
Exception in thread "main" java.lang.UnsupportedClassVersionError: net/sourcefor
ge/jtds/jdbc/Driver : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at de.cenote.jasperstarter.Db.getConnection(Db.java:69)
at de.cenote.jasperstarter.Report.fill(Report.java:220)
at de.cenote.jasperstarter.App.processReport(App.java:222)
at de.cenote.jasperstarter.App.main(App.java:107)
Please advice.
Basically, you are trying to run code that was compiled on / for Java 7 on an older JVM.
That doesn't work.
Either:
run your application on a Java 7 JVM (or later1); i.e. upgrade your Java version,
find a build of the JDTS driver that is suitable for your execution platform, or
find the source for the JDTS driver and build it for your platform.
For more detailed information on this exception and its causes, read:
http://stackoverflow.com/questions/10382929.
1 - Note that even Java 7 is end-of-life now. If you are still running that version of Java you should upgrade.
Make sure you have same JRE and JDK.
If not sure un-install download the latest JDK and try again.
Note that the JDK does install the JRE automatically.