Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Exception in thread "main" java.lang.NoClassDefFoundError

  Asked By: Erica    Date: Apr 26    Category: Java    Views: 1978

i'd like to comple this hello.java:

public class hello {
public static void main (String args[]) {
System.out.println("Hellow world");

ant this is the ouput?

C:\>javac hello.java

C:\>java hello
Exception in thread "main" java.lang.NoClassDefFoundError: hello

why can't this compiled? I use win98 and jdk1.4.



5 Answers Found

Answer #1    Answered By: Norman Ray     Answered On: Apr 26

you got classpath problems ...
read java  / sun manual about setting classpath ...:)
(in installation manual)

Answer #2    Answered By: Leon Evans     Answered On: Apr 26

This is the most common exception  for the new java  developers. Your
current path is not defined in class  path variable so thats why the
error comes. Please type the following line at prompt before running
your program


here I typed the dot means your current directory on the classpath
now and now your class is on the path run it and enjoy.

Let me know, is you problem resolved??

Answer #3    Answered By: Garai Chalthoum     Answered On: Apr 26

If your javac  command (the line that read "javac hello.java") compiled  the
source code with no errors, then
a file named hello.class was created in the directory you ran it from.

If the java  command (the line that read "java hello") gives the error you
mention, it means that the java executable can not find the file hello.class.

Running the command "set" will reveal if you have a CLASSPATH environment
variable set and what it is set to.

You can also specify a classpath when you run the java executable with a
classpath switch in several ways:

java -classpath "C:\" hello


java -classpath %CLASSPATH%;"." hello

Answer #4    Answered By: Caitlin Brown     Answered On: Apr 26

I am interested in learning java  programming from now starting at
beginner`s level.
Would anyone out there please help me on what will be the better ways
of learning it.
Up to now i only have basic skills in pascal programming and i am not
sure whether it will help in anyway or i need some other skills before
attempting java lessons.

Answer #5    Answered By: Mamie Wallace     Answered On: Apr 26

You don't need anything special. You will just need to learn OO programming.
The best thing to do is to actual program, not read books

Didn't find what you were looking for? Find more on Exception in thread "main" java.lang.NoClassDefFoundError Or get search suggestion and latest updates.