Results 1 to 5 of 5
  1. #1
    sumithra is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default exception in "main thread" java.lang.NoclassDefFoundError:hello

    My problem is I have saved hello.java in c:\program files\java\jdk1.5.0_03\bin
    I m able to compile the file but while running the file
    Exception in thread "main" java.lang.NoClassDefFoundError: hello is coming.
    What should i change in class path please help me.
    Thanks in advance

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

    Default

    Quote Originally Posted by sumithra View Post
    My problem is I have saved hello.java in c:\program files\java\jdk1.5.0_03\bin
    I m able to compile the file but while running the file
    Exception in thread "main" java.lang.NoClassDefFoundError: hello is coming.
    What should i change in class path please help me.
    Thanks in advance
    Don't store your files in the directory where all the Java tools are stored. Set you 'path' variable to where those tools are stored and store your .java files somewhere else. The setup is described in the Sun Java Tutorials.

    kind regards,

    Jos

  3. #3
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    Keep the class file with .java file(same directory).

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

    Default

    Quote Originally Posted by Prajin View Post
    Keep the class file with .java file(same directory).
    That isn't even needed; I keep my sources in project directories, as in java/src/project/X/Y/Z.java and my class files in java/classes/X/Y/Z.class. Javac has some flags that tell it where to read sources and where to store .class files. That way I keep my classes together (and separated from my sources) and it's easy to create .jar files from the java/classes hierarchy. My classpath variable just points to the java/classes directory.

    kind regards,

    Jos

  5. #5
    clydedoris is offline Member
    Join Date
    Feb 2010
    Posts
    80
    Rep Power
    0

    Default

    you can place your classes anywhere you want but the PATH environment var should be pointed to the compiler..
    [why are you annoyed with my sig?]

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: 5
    Last Post: 09-29-2009, 12:14 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
  •