...

View Full Version : java.lang.UnsupportedClassVersionError: Bad version number in .class file



littlemiss
02-25-2008, 02:35 PM
Hey,

Its a strange one, I have not edited Eclipse in anyway, but every time i try to compile my program i get the following error:

java.lang.NoClassDefFoundError: Draw
Exception in thread "main"

The program was working a week ago, I have no edited it at all i tried to run it the next day and this error came up.

I am now having to code in notepad and compile using the cmd, its really causing problems, does anybody have any idea what this error is and how to fix it?


oh it seems to not just be eclipse anymore, the cmd gave out the following stuff when i tried to run


C:\Documents and Settings\workspace\ProjectMobile>java GUI.java
Exception in thread "main" java.lang.NoClassDefFoundError: GUI/java
Caused by: java.lang.ClassNotFoundException: GUI.java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Rappa
02-25-2008, 02:37 PM
I suppose it would help if you posted your code.

littlemiss
02-25-2008, 02:39 PM
Its not the code. I created a simple hello world program in a new project and it had the same error.

sobrien79
02-25-2008, 02:55 PM
Have you tried reinstalled eclipse?

littlemiss
02-25-2008, 03:03 PM
Yeah i tried installing some plug ins, then i tried re installing, then i tried installing easyeclipse and its all the same error, its really weird, i have no clue whats going on!

littlemiss
02-25-2008, 03:16 PM
I tried to run my program using the cmd, and now that doesnt work! Here is the info it gave out



C:\Documents and Settings\workspace\ProjectMobile>java GUI.java
Exception in thread "main" java.lang.NoClassDefFoundError: GUI/java
Caused by: java.lang.ClassNotFoundException: GUI.java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Anybody know what this means?

littlemiss
02-25-2008, 04:05 PM
It seems eclipse has made a java app called draw some where, i dont know where, but i tried running things and this new error came up:

java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
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 Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Its similar to the cmd error, but i dont understand what it means

Aradon
02-25-2008, 06:23 PM
In order to compile a java program inside of the command line (cmd) then you have to use javac, NOT java.

So you would do:



javac GUI.java
java GUI


Notice that on java GUI, the .class or .java is not present! Also we will need to see your draw.java code if we are to figure out what is going on with eclipse.

mehagrover
05-15-2009, 11:54 AM
" Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file"
this is because the code was compiled on a new version of java and u r trying to run it onthe older version of java. Please make sure that both the versoins are same.:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum