Results 1 to 7 of 7
- 06-20-2011, 05:46 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 3
- Rep Power
- 0
Error while running jar outside of IDE
I have a program that compiles and runs well in NetBeans. When I create a jar file and try to run on my linux via CLI, I get the following:
[root@lizard dist]# java -jar AxisCamera.jar
Exception in thread "main" java.lang.ClassFormatError: axiscamera.axiscamera (unrecognized class file version)
at java.lang.VMClassLoader.defineClass(libgcj.so.7rh)
at java.lang.ClassLoader.defineClass(libgcj.so.7rh)
at java.security.SecureClassLoader.defineClass(libgcj .so.7rh)
at java.net.URLClassLoader.findClass(libgcj.so.7rh)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj .so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
Does this have to do with my import statements or CLASSPATH or something else?
Thanks in advance?
- 06-20-2011, 06:13 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Exceptions such as this occur when trying to compile and run with differing version of the JDK and JVM. For even more detail, check the versions you are using of each (eg 'java -version' and 'javac -version'). Try updating the JVM on the machine you are attempting to run the jar on, or compile and specify the minor version (may not be possible if your code requires later versions of the java API)
- 06-20-2011, 06:14 PM #3
It could do with different versions of java. Compile with younger, execute with older.
Or it could be a corrupted class file. Can you extract the class file mentioned and look at the first few bytes in a hex editor. They should look like this:
CAFEBABE0003002D001401000443
- 06-20-2011, 08:38 PM #4
Member
- Join Date
- Jun 2011
- Posts
- 3
- Rep Power
- 0
# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-50)
# javac -version
Eclipse Java Compiler v_677_R32x, 3.2.1 release, Copyright IBM Corp 2000, 2006. All rights reserved.
I think you are correct. I did the same two commands on my MAC where the app works and it shows 1.6.0_24 for both java and javac. Would this be a $PATH issue?
- 06-20-2011, 08:44 PM #5
It appears that you are not using Oracle's java or javac commands. Have you tried installing the JDK vs using gij?
- 06-20-2011, 08:53 PM #6
Get rid of the silly GNU Java aka 'Fake Java' and install a Sun/Oracle JRE (or JDK if you want to develop on the Linux box).
db
- 06-20-2011, 09:06 PM #7
Member
- Join Date
- Jun 2011
- Posts
- 3
- Rep Power
- 0
Ok, on RHEL where this wasn't working I had to re-link the symbolic link in /etc/alternatives/java to my jdk. This is what I did:
# rm /etc/alternatives/java
rm: remove symbolic link `/etc/alternatives/java'? y
# ln -s /usr/java/jdk1.6.0_25/bin/java /etc/alternatives/java
All is well now. Thanks everyone for pointing out the version mismatch.
Similar Threads
-
Java running error
By distant_smile in forum New To JavaReplies: 10Last Post: 01-23-2011, 06:19 AM -
Runtime Error running in UVA
By mathfxr in forum Advanced JavaReplies: 10Last Post: 09-18-2010, 01:50 AM -
Odd error when running app
By pahiker in forum New To JavaReplies: 5Last Post: 06-23-2010, 03:10 PM -
Error during running
By ak88 in forum New To JavaReplies: 7Last Post: 07-28-2009, 04:39 AM -
error while running jar file
By ernieBob in forum NetBeansReplies: 1Last Post: 03-25-2008, 11:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks