[ben@benlinux helloworld]$ java HelloWorldApp
Exception in thread "main" java.lang.ClassFormatError: HelloWorldApp
(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)
any ideas what could be the problem?
cheers
It's basically saying that the java interpreter is unable to read the
compiled program. This may be because your compiler targets a different
version of Java than your interpreter, or because some mistake occurred
while compiling leading to a corrupt file.
How did you compile the Java program?
- Oliver
I did it using "javac HelloWorldApp.java".
Could it be that it's somehow trying to compile with gcc, and run with
JDK - or the other way round? I thought that could be the problem but
i don't know enough about java to find out or fix it. But surely
"java" and "javac" are both JDK programs ... aren't they? Or could it
be using the version of "java" to run it that it previously had
installed, rather than the JDK version?
Ah, i've solved it - for some reason /usr/bin/java was pointing to /
etc/alternatives/java instead of /usr/java/default/bin/java.
Thanks for the input
It looks like your system has a conflict between the Sun Java installation and
an existing gcj installation.
Check exactly what executable the "java" command runs (and also javac). It might
be that you've used a recent Sun SDK javac compiler to create the classes, but
the java command is an older version of java (from gcj).
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : n...@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
Or instead of updating /etc/alternatives/ to point to the latest java.
The "some reason" is that the alternatives mechanism is the cleanest way to
maintain versions, and allows different users / processes to use different
versions.
- Lew