I have generated .jar file in windows.
I have to execute that .jar file in unix .
I am running that command (java -jar myJar.jar
), but it's giving
java.lang.UnsupportedVersionError
I am using java version 1.5.0.12 in Unix.
I have generated .jar file in windows.
I have to execute that .jar file in unix .
I am running that command (java -jar myJar.jar
), but it's giving
java.lang.UnsupportedVersionError
I am using java version 1.5.0.12 in Unix.
You should also keep in mind that JVM are not forward compatible, so if you've made a jar-file using JDK 1.6, it won't work with JDK 1.5!
In this case you may either:
install JDK 1.6 to Unix
recompile the jar with -target 1.5
flag (but you may get any sort of errors due to API incompatibilities, so the first way is much better)
Have you tried using a newer version of Java on your Unix system?
If you control the jar file, could you target Java 1.5 when it's compiled?
java.lang.UnsupportedVersionError
You must be trying to launch a jar compiled with JDK6, with a local java1.5.
You can either:
:
javac -source 1.5 -target 1.5 -bootclasspath /path/to/jre1.5/lib/rt.jar
to check if you can generate 1.5 bytecode compatible.
UnsupportedVersionError
means that you have compiled the Java source code with a newer version of Java than what you're trying to run it with. Java is downwards compatible (newer versions of Java can run Java programs compiled with older versions), but not upwards compatible (older versions of Java cannot run Java programs compiled with newer versions).
You say you're using Java 5 on Unix. Did you compile it using Java 6 on Windows? Then it's obviously not going to work.
Possible solutions:
-source 1.5 -target 1.5
while you compile (this will not protect you against using Java 6-only classes from the standard library, so this is not a full guarantee that your program will run without errors on Java 5)Recompile your application with Java 5 on your Windows machine.
(Java 6 generates Java 6 compatible byte code by default to use new facilities. The easiest for you is to install a Java 5 JDK and use it to recompile your application)