Reputation: 161
I've made a client for my game and I wanted to jar it, I used jarmaker and did I'm sure I did everything correctly, but when I try to open the .jar file, it says "A java exception has occurred" any help is appreciated.
Exception in thread "main" java.lang.UnsupportedClassVersionError: client : 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)
Press any key to continue . . .
Upvotes: 3
Views: 267228
Reputation: 181
This error usually happens when compiled in higher JDK version and ran in the lower version of JDK and if your code has some features present in the higher versions. Usually this happens because by default in the OS if java -version
is searched it might show some old JDK version, so either change global env variable's value if you have privileges to do so else e.g., in linux instead of typing only 'java' while executing, type the complete path e.g., /usr/jav/jdk1.8/bin/java <<.class||.jar>>
. This will resolve the issue.
Upvotes: 2
Reputation: 620
I generate JAR file in NetBeans
once I double click on JAR file I got an error
A Java Exception has occurred.
I just create new folder put JAR file inside that folder and also place lib folder that is used for Java project and finally JAR file is working fine.
Upvotes: 2
Reputation: 631
Upgrade the jdk version. You can upgrade it by uninstalling the older version from control panel and installing newer version of jdk. Get the new version here http://www.oracle.com/technetwork/java/javase/downloads/index.html
Upvotes: 2
Reputation: 4899
You compiled your jar with a JDK version superior to the JDK used to launch the jar file (you might have compiled with 1.7 and try to run it with 1.6).
2 solutions:
-target 1.6
to you compiler options)Upvotes: 10