UnsupportedClassVersionError

Hi,

I changed the classpath variable to refer to a couple of .jar files earlier then I cleared the classpath by doing 'set classpath='.

Now suddenly I cant even run a HelloWorld file. I can compile code but when i try to run it I get:

Exception in thread "main" java.lang.UnsupportedClassVersionError:

orted major.minor version 49.0)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Sour

at java.net.URLClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.access$100(Unknown Source)

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Metho

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Sourc

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

What is the problem here?

THANKS very much for anyones help!

[1169 byte] By [glow360a] at [2007-10-2 20:11:35]
# 1

seems you don't have a 5.0 compliant JRE installed or if you do have one installed it's not the one your operating systems uses when running Java classfiles.

Check your system and user paths for old java and javaw executables and either remove those or juggle the path such that they're not chosen over your 5.0 compliant JVM (which you may need to install first).

jwentinga at 2007-7-13 22:52:09 > top of Java-index,Java Essentials,New To Java...
# 2

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/UnsupportedClassVersionError.html

The error means you are running a class file compiled with a version not supported by the JVM you are running it in. 49.0 means 1.5, so you are probably trying to run a 1.5 compiled class in a 1.4 or older JVM.

Solutions are to run in a 1.5 JVM, to compile with a 1.4 compiler (if possible), or to use a bytecode manipulator like RetroWeaver, to make your 1.5 classes run on older JVMs.

Lokoa at 2007-7-13 22:52:09 > top of Java-index,Java Essentials,New To Java...
# 3

Thanks for your advice....I did recently uninstall j2sdk1.4 and installed Java 5.0 that came along with Netbeans 4.1 IDE (running in Netbeans worked fine but not in Dos command prompt).

How do I check the system files to make sure that the JVM the windows XP OS uses is the latest one? (Sorry if this question sounds stupid). The path is already set to my new Java folder and the classpath is empty at the moment.

Will uninstalling and reinstalling Java 5.0 be better?

Thanks very much again.

glow360a at 2007-7-13 22:52:09 > top of Java-index,Java Essentials,New To Java...
# 4

If you type

java -version

on a command line you can see which is the default JVM in use by the OS.

You should either start your application with a batch file that explicitly starts the 1.5 java_exe, or you can change your system's PATH variable to point to the java.exe you want.

I don't think reinstalling 1.5 will help at all.

Message was edited by:

Loko

Lokoa at 2007-7-13 22:52:09 > top of Java-index,Java Essentials,New To Java...
# 5
Thanks alot guys...its working fine now....
glow360a at 2007-7-13 22:52:09 > top of Java-index,Java Essentials,New To Java...