Results 1 to 6 of 6
  1. #1
    sagarkha is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default Newbie in Java -- Exception in thread "main" java.lang.NoClassDefFoundError:

    Hello Everybody

    I am very new to java and i am getting error while running my first java program HelloWorld. Its running on Win XP system with jdk-6u22-windows-i586.exe installed.

    I have added CLASSPATH to the user variables where all my class files are stored but no help. I was pretty sure that i would find an existing thread on this forum related to this post but i was not able to find any thread.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,000
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by sagarkha View Post
    I am very new to java and i am getting error while running my first java program HelloWorld.
    It would help us tremendously if we'd know what the exact error was ...

    kind regards,

    Jos

  3. #3
    sagarkha is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    Error is already posted in subject line

    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class
    Caused by: java.lang.ClassNotFoundException: HelloWorld.class
    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)
    Could not find the main class: HelloWorld.class. Program will exit.

    And i am getting this error while running the command java HelloWorld.class

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,000
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by sagarkha View Post
    Error is already posted in subject line

    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class
    Caused by: java.lang.ClassNotFoundException: HelloWorld.class
    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)
    Could not find the main class: HelloWorld.class. Program will exit.

    And i am getting this error while running the command java HelloWorld.class
    Don't do that; run your class like this:

    Java Code:
    java HelloWorld
    kind regards,

    Jos

  5. #5
    sagarkha is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    It worked...thanks

  6. #6
    marlon9472 is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    guys i'm gettin a message that is something like that its sayin0



    Exception in thread "main" java.lang.NoClassDefFoundError: client
    Caused by: java.lang.ClassNotFoundException: client
    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)
    Could not find the main class: client. Program will exit.
    Press any key to continue . . .


    it says when i try to run a server for a game. please help

Similar Threads

  1. Replies: 12
    Last Post: 06-06-2012, 09:04 AM
  2. Replies: 5
    Last Post: 06-02-2010, 01:05 PM
  3. Replies: 3
    Last Post: 06-01-2010, 03:01 PM
  4. Replies: 1
    Last Post: 04-02-2009, 09:50 PM
  5. Replies: 6
    Last Post: 08-18-2008, 06:44 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
  •