Results 1 to 6 of 6

Thread: Help with error

  1. #1
    afflictedd2 is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default Help with error

    Hi everyone,

    I'm getting this error, and I'm not sure how to fix it. I've deleted and built the file again, but I keep getting the same 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 :676)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.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.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 17)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:280)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:375)

    Any help appreciated,
    Ted

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,563
    Blog Entries
    7
    Rep Power
    21

    Default

    Check the version of your compiler (javac -version) against the version of your jvm (java -version); they should match; also search for that class file, maybe an (old) copy is still stored somewere.

    kind regards,

    Jos

  3. #3
    afflictedd2 is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default

    Hmm they match, I'm using eclipse, and things are a little messed up there because it has this Java version 1.6 that is unbound*

    // java version "1.5.0_22"
    // Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03-333-9M3125)
    // Java HotSpot(TM) Client VM (build 1.5.0_22-147, mixed mode, sharing)

    // javac 1.5.0_22
    // javac: no source files

    Is there a way to determine what version the class file has been compiled with.

    Ted

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,563
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by afflictedd2 View Post
    Is there a way to determine what version the class file has been compiled with.
    If you compiled your class with Eclipse, go to Project>Properties>Java Compiler; in the right panel you can see the compliance level of the compiler. Set it to 1.5 (the version of your jvm).

    kind regards,

    Jos

  5. #5
    afflictedd2 is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default

    aghh I tried that, it still doesn't work :(. The file has a lot of dependencies (other classes referenced) as well, so i'm also wondering if the problem is there, as they might be compiled on a different version, and eclipse doesn't seem to have a clean rebuild option.
    Last edited by afflictedd2; 05-07-2010 at 08:49 PM.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,563
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by afflictedd2 View Post
    aghh I tried that, it still doesn't work :(. The file has a lot of dependencies (other classes referenced) as well, so i'm also wondering if the problem is there, as they might be compiled on a different version, and eclipse doesn't seem to have a clean rebuild option.
    Eclipse has several options for that: you can start it from the shell (command line) with the -clean option, i.e. type "eclipse -clean"; alternatively you can go to Project>Clean ... and select the clean all projects option.

    The last alternative is to select all projects in the package pane and press F5. Don't forget to set the compiler compliance to 1.5 for all your projects.

    kind regards,

    Jos

Similar Threads

  1. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  2. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  3. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  4. Replies: 3
    Last Post: 01-23-2009, 08:53 AM
  5. error 530 error authentication required
    By rgale in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-12-2008, 04:28 PM

Posting Permissions

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