Results 1 to 18 of 18
Like Tree1Likes
  • 1 Post By Fubarable

Thread: NoClassDefFoundError

  1. #1
    PeDz is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Default NoClassDefFoundError

    public class HelloWorld {

    public static void main (String[] args){

    System.out.print("Hello World!");

    }
    }
    -------------------------------------------------------
    This is my code but when i run it, I get this:

    java.lang.NoClassDefFoundError: HelloWorld/java
    Caused by: java.lang.ClassNotFoundException: HelloWorld.java
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
    Could not find the main class: HelloWorld.java. Program will exit.
    Exception in thread "main"
    Process completed.


    Please HELP!! I really need to fix this..

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

    Default Re: NoClassDefFoundError

    You haven't compiled your sources yet and you are trying to run your HelloWorld.java source file.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: NoClassDefFoundError

    You left off the command that you issued to get the error message.

    You must have used the java command instead of the javac command.
    See:"Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)

  4. #4
    PeDz is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Default Re: NoClassDefFoundError

    thankz for ur comment and i appreciated it...
    im using JCreator Pro and I'm sure that not the problem...
    I think the classpath or watever.. but i set my classpath to the JDK/bin

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: NoClassDefFoundError

    i set my classpath to the JDK/bin
    That is where the path should point, not the classpath. The bin folder contains .exe files and the path is used by the OS to find them.
    The classpath is used to find the definition of class by javac.exe and java.exe

    Did you compile your source file and create a .class file?

    You need to get advice on how to use your IDE. There is a part of this forum for IDEs. Try asking about your problem there.

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

    Default Re: NoClassDefFoundError

    Quote Originally Posted by PeDz View Post
    thankz for ur comment and i appreciated it...
    im using JCreator Pro and I'm sure that not the problem...
    I think the classpath or watever.. but i set my classpath to the JDK/bin
    Have you compiled your class? Your inital attempt clearly showed that you were trying to run a .java file; .java files contain your source code and cannot be run. You need to compile your source file and produce a .class file; .class files can be run. Read a tutorial on the basics before you are trying to do something.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    PeDz is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Default Re: NoClassDefFoundError

    yeah... there's a .class file produced...
    this problem started when i used the prompt for main method from CONFIGURE>OPTIONS>JDK TOOLS>DEFAULT>EDIT>PARAMETER

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: NoClassDefFoundError

    There is a part of this forum for IDEs. Try asking about your problem there.

  9. #9
    PeDz is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Default NoClassDefFoundError

    public class HelloWorld {

    public static void main (String[] args){

    System.out.print("Hello World!");

    }
    }
    -------------------------------------------------------
    This is my code but when i run it, I get this:

    java.lang.NoClassDefFoundError: HelloWorld/java
    Caused by: java.lang.ClassNotFoundException: HelloWorld.java
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
    Could not find the main class: HelloWorld.java. Program will exit.
    Exception in thread "main"
    Process completed.


    Please HELP!! I really need to fix this..

  10. #10
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: NoClassDefFoundError

    HelloWorld.java is not a class file, it is a source file. Did you compile? How are you trying to run the program?
    Suggested reading: Lesson: The "Hello World!" Application (The Java™ Tutorials > Getting Started)

  11. #11
    PeDz is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Default Re: NoClassDefFoundError

    yeah i compied it... this problem started when i used the "prompt for main method" from
    CONFIGURE>OPTIONS>JDK TOOL>PARAMTERS

  12. #12
    PeDz is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Default Re: NoClassDefFoundError

    i did but no one's helping... I'm doomed T_T

  13. #13
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: NoClassDefFoundError

    Please don't violate forum rules and double post:
    NoClassDefFoundError

  14. #14
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: NoClassDefFoundError

    Please don't violate forum rules and double post
    NoClassDefFoundError

    i did but no one's helping... I'm doomed T_T
    That's a great way to thank those that are trying to help

  15. #15
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: NoClassDefFoundError

    Quote Originally Posted by doWhile View Post
    Please don't violate forum rules and double post
    NoClassDefFoundError
    I can't say that I blame him as he was suggested to do this by a moderator. Though for my money, I'd just as soon move this over to the IDE section myself, and in fact I think that I'm going to do just that.

    Edit: instead, I just merged threads. This may be a little confusing...
    Last edited by Fubarable; 02-05-2012 at 06:17 PM.
    DarrylBurke likes this.

  16. #16
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: NoClassDefFoundError

    Quote Originally Posted by Fubarable View Post
    I can't say that I blame him as he was suggested to do this by a moderator.
    Sorry...missed that. Thanks for merging them (I don't like contributing to one post to find a full blown discussion elsewhere in response to the exact same thing).

  17. #17
    PeDz is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Default Re: NoClassDefFoundError

    im really sorry... can u advice me what to do in my problem?? i cant start my chat project if i cant solve this... plz i really need some advice...

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: NoClassDefFoundError

    Try using the command line for compiling and and executing the code.

Similar Threads

  1. NoClassDefFoundError
    By PeDz in forum New To Java
    Replies: 10
    Last Post: 02-05-2012, 06:14 PM
  2. NoClassDefFoundError
    By PeDz in forum Advanced Java
    Replies: 1
    Last Post: 02-04-2012, 02:44 PM
  3. NoClassDefFoundError
    By sriram56 in forum IntelliJ IDEA
    Replies: 0
    Last Post: 11-26-2011, 03:04 AM
  4. NoClassDefFoundError
    By bmeu in forum JDBC
    Replies: 1
    Last Post: 10-30-2010, 08:08 PM
  5. NoClassDefFoundError
    By Josisco in forum JDBC
    Replies: 2
    Last Post: 10-30-2010, 08:07 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
  •