-1

I created a jar file in my laptop and it runs fine in my computer without trouble but when i use the same in my friend's laptop it shows and exception and the file does not run. But it's still good with my laptop. What's the reason?

name of jar =BlueServer.jar it has only one class.
classname=Server.java one external library is used name=Bluecove.jar which is used for accessing bluetooth from java. Ide used=Eclipse used Eclipse for creating jar,already checked the option "Pacakage required libraries into generated jar"

This Error came while i try to run that same jar in another computer....

java -jar BlueServer.jar Exception in thread "main" java.lang.UnsupportedClassVersionError: Server : Unsupported major.minor version 51.0

    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
  • Then i have to check for each user of my jar have higher jdk or lower. Is there any general method so that i will not bother about the version of jdk of the user of that jar – Shekhar Kumar Apr 14 '14 at 10:52
  • @ShekharKumar Not in general, but usually if you set the compiler to java 5 (aka 1.5) you should not have this problem anymore nowadays. – SebastianH Apr 14 '14 at 11:14

3 Answers3

0

It is a problem with the version of the used JRE. See this post for details. Try

java --version

on both machines.

Community
  • 1
  • 1
SebastianH
  • 2,172
  • 1
  • 18
  • 29
0

This error indicates, that your file is not executable with the installed JRE version.

See How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version for more info about that.

Community
  • 1
  • 1
0x8BADF00D
  • 962
  • 1
  • 8
  • 18
  • Then i have to check for each user of my jar have higher jdk or lower. Is there any general method so that i will not bother about the version of jdk of the user of that jar – Shekhar Kumar Apr 14 '14 at 10:52
0

java.lang.UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime. Make sure the jdk version installed in your laptop is equal or higher than your friend's.

yogesh
  • 574
  • 6
  • 24