tags:

views:

458

answers:

1

Hello All

I am trying to run an Java Applet application that ran fine on Windows XP (using Eclipse IDE) but after I imported the project on MacOS X (Using Eclipse on MacOS too), it fails to run displaying this error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:675) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(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:316) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) at edu.isi.calo.mapping.gui.DieselUtil.(DieselUtil.java:9) at edu.isi.diesel.DieselEditor.processSettingsFile(DieselEditor.java:597) at edu.isi.diesel.DieselEditor.main(DieselEditor.java:80)

Has anybody faced such a problem? I deleted all the class files and built the whole project again but it still pops up this runtime error.

+3  A: 

What that message is telling you is that your JRE does not know how to execute the class because the class has too new a version. Two obvious questions are:

  1. What version of the JRE do you have on Windows XP?
  2. Do you have Apple's latest distro of the JRE, which is supposed to support Java 6?

I would guess that the version of the JRE you're using know is pre-Java 5.

Matthew Flaschen
-agree. That Error happens when some class (maybe in a 3rd party Jar, not your code) was compiled with a newer JDK than what you are running. It typically only happens for different major versions (1.4-1.5, 1.5-1.6, ...).
John Meagher
you can check the version by using the Java Preferences application on os X.
Milhous
It helped me solve the problem! Thanks a lot :) Eclipse was using JRE 1.5 as default environment. Changing it to 1.6 solved the problem.
shuby_rocks