Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts

    java.lang.UnsupportedClassVersionError: Bad version number in .class file

    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)
    Last edited by littlemiss; 02-25-2008 at 04:25 PM.

  • #2
    Regular Coder Rappa's Avatar
    Join Date
    Nov 2005
    Location
    LI
    Posts
    356
    Thanks
    21
    Thanked 9 Times in 9 Posts
    I suppose it would help if you posted your code.

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Its not the code. I created a simple hello world program in a new project and it had the same error.

  • #4
    Regular Coder
    Join Date
    Jan 2008
    Location
    Willow Grove, PA
    Posts
    169
    Thanks
    1
    Thanked 27 Times in 27 Posts
    Have you tried reinstalled eclipse?

  • #5
    New Coder
    Join Date
    Aug 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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!

  • #6
    New Coder
    Join Date
    Aug 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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?

  • #7
    New Coder
    Join Date
    Aug 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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

  • #8
    Regular Coder Aradon's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    734
    Thanks
    0
    Thanked 20 Times in 19 Posts
    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:

    Code:
    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.
    "To iterate is human, to recurse divine." -L. Peter Deutsch

  • #9
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    " 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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •