• Post Reply Bookmark Topic Watch Topic
  • New Topic

java. lang.NoClassDefFoundError  RSS feed

 
shan Iyer
Ranch Hand
Posts: 391
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,

I am getting he following exception even though the path and classpath have been set properly !

Path and classpath are set as follows :
path = c:\program files\java\j2sdk1.5.0\bin
classpath = c:\program files\java\j2sdk1.5.0\lib

However , the error I get for a simple hello world program is :

Exception in thread "Main" java.lang.NoClassDefFoundError : helloworld
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should probably put a dot in your classpath, or try running it with

java -cp . <classname>

(i think i have that syntax correct...)
 
shan Iyer
Ranch Hand
Posts: 391
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java -cp . <classname>


Does Not Work .
I have tried verything :

1.) putting a dot in classpath
2.) running it with java -classpath.hello and java -cp.hello
3.) setting classpath to c:\Program Files\java\j2sdk1.5.0\bin and also to c:\Program Files\java\j2sdk1.5.0\lib and compiling , executing the source code in the bin directory
4.) Have NOT used any package . Source file is directly under c:\ and am compiling and executing in c:\ itself
5.) Reinstalling j2sdk1.5.0 again .

BUT THE ERROR PERSISTS ! PLEASE HELP .
 
shan Iyer
Ranch Hand
Posts: 391
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am NOT using any IDE .
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I assume you have given the wrong class name. Check your file name. For example : If your class name is hello, you should give java hello instead of helloword

bye for now
sat
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the name of the file? What is the name of the class? they must match, exactly. helloWorld is NOT the same as helloworld. You must call the class with the correct name as well. Can you paste the complete text of your code here?
 
shan Iyer
Ranch Hand
Posts: 391
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I FOUND OUT!!

The problem was a missing semicolon in the classpath declaration .
classpath = %classpath%;c:\Program Files\Java\j2sdk1.5.0\lib ;

The semicolon at the end was missing .
Phew!! Had a really tough time fixing this . Another reason to laugh at a MicroSoft product and goes to show how MicroSoft products can ruin your peace!!
[ February 04, 2007: Message edited by: Shankar Iyer ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!