Results 1 to 10 of 10
Like Tree2Likes
  • 1 Post By kkid
  • 1 Post By kammce

Thread: Exception in thread main java.lang.NoClassDefFoundError

  1. #1
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    226
    Rep Power
    3

    Default Exception in thread main java.lang.NoClassDefFoundError

    I am new to java programming, it is also the first ever language I have tried to learn so am very new at debugging.

    I have compiled my simple program perfectly fine, I got the class file output as normal, however I have a run-time issue. I get the following message:

    Exception in thread main java.lang.NoClassDefFoundError-javaissue.png

    What is wrong, how do I fix it?

    This is my source code:

    Java Code:
    class Operators {
    public static void main(String[] args) {
    
    double first = 4.0;
    double second = 6.0;
    
    System.out.println("The first value equals " + first);
    System.out.println("The second value equals " + second);
    System.out.println(" ");
    System.out.print("These two values added together equals ");
    System.out.println(first + second);
    System.out.print("The second value minus the first equals ");
    System.out.println(second - first);
    System.out.print("The product of these two values ");
    System.out.println(first * second);
    System.out.print("The second value divided by the first equals ");
    System.out.println(first / second);
    
    
    }
    }

    Thanks for reading

  2. #2
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    226
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    Updated code, same issue:

    Java Code:
    class Operators {
    public static void main(String[] args) {
    
    double first = 4.0;
    double second = 6.0;
    
    System.out.print("The first value equals ");
    System.out.println(first);
    System.out.print("The second value equals ");
    System.out.println(second);
    System.out.println(" ");
    System.out.print("These two values added together equals ");
    System.out.println(first + second);
    System.out.print("The second value minus the first equals ");
    System.out.println(second - first);
    System.out.print("The product of these two values ");
    System.out.println(first * second);
    System.out.print("The second value divided by the first equals ");
    System.out.println(first / second);
    
    
    }
    }

  3. #3
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    It says at the very top next to the error:

    Java Code:
    (wrong name: Operators)
    Does that help?
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  4. #4
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    226
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    Can't I use "Operators" as the class name then?
    Is it a keyword?

  5. #5
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    Double check exactly what you typed into the command line.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  6. #6
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    226
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    OMG!

    It was just because I typed "operators" instead of "Operators"?!
    awinston likes this.

  7. #7
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    Yes.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  8. #8
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    226
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    haha, thanks for your help.

    I thought it was more complex than that.

    So the compiler doesn't need capitals but the VM does?

  9. #9
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    Apparently so. I didn't realize the compiler didn't require it, so thank you for that information.

    I always assume that everything is case-sensitive just as a precaution!
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  10. #10
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: Exception in thread main java.lang.NoClassDefFoundError

    Quote Originally Posted by kkid View Post
    haha, thanks for your help.

    I thought it was more complex than that.

    So the compiler doesn't need capitals but the VM does?
    Just to make a statement. The Windows Command-line is NOT case sensitive. The VM is though. But other terminals like BASH, CShell and other *nix terminals are case case-sensitive. That does not mean you should not start typing everything in there with all caps.
    awinston likes this.
    My API:
    Java Code:
    cat > a.out || cat > main.class

Similar Threads

  1. Replies: 5
    Last Post: 06-02-2010, 01:05 PM
  2. Replies: 3
    Last Post: 06-01-2010, 03:01 PM
  3. Replies: 1
    Last Post: 04-02-2009, 09:50 PM
  4. Replies: 6
    Last Post: 08-18-2008, 06:44 AM
  5. Replies: 1
    Last Post: 08-06-2007, 06:07 AM

Posting Permissions

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