3

This is what I get:

[user@localhost KioskMenu]$ java -jar ./kioskmenu.jar 
Exception in thread "main" java.lang.ClassFormatError: KioskMenu (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)
[user@localhost KioskMenu]$ 

The only thing I noticed was that my RHEL is using a "free" version of Java. But this shouldn't matter should it?

  • I pasted the wrong code block. I edited my question. –  Aug 15 '11 at 15:23
  • 2
    Which Java compiler did you use, including version number? Also, can you include the output of `java -version`? – Matt Solnit Aug 15 '11 at 15:25
  • Does the command `jar -tvf kioskmenu.jar` list the correct classes? How did you get the jar file on linux? (If ftp, did you specify binary transfer mode?) – rsp Aug 15 '11 at 15:30

2 Answers2

5

You compiled the jar with a newer version of Java than the one on your Linux machine.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
  • You're right, I compiled with 1.6 and am trying to run with 1.4. Will accept in 4 minutes. –  Aug 15 '11 at 15:28
1

You should really be doing this:

java -jar ./kioskmenu.jar

Notice the -.

If you just give java jar ./kioskmenu.jar, the JVM is trying to find a class named jar and trying to pass ./kioskmenu.jar as an argument to it - which is clearly not what you want.

adarshr
  • 61,315
  • 23
  • 138
  • 167