Results 1 to 4 of 4
  1. #1
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Question NoClassDefFoundError

    :confused:....why doesn't this compile?

    TestOne.java
    --------------
    public class TestOne {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    int x = 0;
    //assert (x != 500); should break
    x = 500;
    }

    }

    Error:
    -----
    Exception in thread "main" java.lang.NoClassDefFoundError: TestOne
    Caused by: java.lang.ClassNotFoundException: TestOne
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
    Press any key to continue . . .
    Last edited by jon80; 05-18-2008 at 08:49 AM. Reason: update #1

  2. #2
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    6

    Default

    It does compile and run! What do you mean? Where do you try to compile/run it? Provide more information about the cintext.
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  3. #3
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Default

    hmm...it did not run somehow on my laptop, although now it ran on one of my virtual machines. Both machines run WinXP and have Java 1.6.

    It is noted that the error reappeared when using the -enableassertion flag:

    C:\Documents and Settings\Administrator.SERVER02\Desktop>java -enableassertions
    TestOne
    Exception in thread "main" java.lang.NoClassDefFoundError: TestOne
    Caused by: java.lang.ClassNotFoundException: TestOne
    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)

    C:\Documents and Settings\Administrator.SERVER02\Desktop>
    Last edited by jon80; 05-18-2008 at 10:58 AM. Reason: update #1

  4. #4
    Jman is offline Member
    Join Date
    Dec 2007
    Posts
    17
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 07-21-2012, 01:15 AM
  2. java.lang.NoClassDefFoundError: com.ibm.ws.orb.GlobalORBFactory
    By hawkeye in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 06-16-2008, 10:56 AM
  3. java.lang.NoClassDefFoundError
    By J_a_y in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 11:51 AM
  4. java.lang.NoClassDefFoundError
    By fred in forum Advanced Java
    Replies: 3
    Last Post: 08-01-2007, 05:00 PM
  5. Replies: 3
    Last Post: 08-01-2007, 04:34 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
  •