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

NoClassDefFoundError

 
ShivaK Thadakamadla
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I had written a HelloWorld program HelloWorld.java
class HelloWorld{
public static void main (String a[]){
System.out.println("hello...")
}
}
The program will compile fine.
When i execute the program it is giving the runtime error java.lang.NoCalassDefFoundError
The work around for this is to set the CLASSPATH variable to . (dot)
But why do we need to explicitely tell the interpreter to look for the classes in the current folder.
According to java tutorial the java interpreter by default looks for the classes in the current directory.
This problem is not happening in other machine..
Why is this is happening .
Iam using jdk 1.3
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ShivaK Thadakamadla:
This problem is not happening in other machine..


actually, i got same problem before. sometimes you have to add the current directory to the path. it is wired.
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
take a look at Class java.lang.NoClassDefFoundError
 
Dhamodharan Krishnan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me assume that you use WINNT machine.
Please verify whether the CLASSPATH variable is set in your Environment variable.
Since you have said that it works in other machine. I do think this could be the possibility.
Sorry if you dont use WINNT.
 
Gary McGath
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Details on classpath are found at http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html.
The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.
 
John Lee
Ranch Hand
Posts: 2545
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic