Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang. NoClassDefFoundError

 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i havent had this problem before with setting up java on my computer but even with the most simple of programs

public class test {
public static void main(String args[]) {
}
}

i get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: test

anyone know why this is?

thanks
Deyna
 
vignesh hariharan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after installing java that doesnt mean that you can compile and run any java program directly.. you are supposed to set the path and then the class path too. just check if you have set those correctly.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vignesh hariharan:
after installing java that doesnt mean that you can compile and run any java program directly.. you are supposed to set the path and then the class path too. just check if you have set those correctly.


No, you don't set the CLASSPATH - not for installation - not ever. My best guess is that the OP has set the CLASSPATH and is now observing problems as a result.

Try:
> java -cp . test

from the directory that contains test.class.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had that error the other day because i tried to compile

javac Test.java

instead of:

test.java
 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fixed, seems quicktime had messed up my classpaths, all sorted now.

thanks for the help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic