Meaningless Drivel is fun!
The moose likes Java in General and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic


ShivaK Thadakamadla

Joined: May 21, 2003
Posts: 4
I had written a HelloWorld program
class HelloWorld{
public static void main (String a[]){
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

Joined: Aug 05, 2001
Posts: 2545
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

Joined: Aug 05, 2001
Posts: 2545
take a look at Class java.lang.NoClassDefFoundError
Dhamodharan Krishnan

Joined: Nov 07, 2001
Posts: 23
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.

Dhamodharan Krishnan,<br />Sun Microsystems, Bangalore<br />Direct : 91-80-4184 7247<br />Cell : 91-99 80 147 600
Gary McGath
Ranch Hand

Joined: Mar 15, 2003
Posts: 52
Details on classpath are found at
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

Joined: Aug 05, 2001
Posts: 2545
here are more links:
Setting the class path
Java Tip 105: Mastering the classpath with JWhich
Classpath Info Page
I agree. Here's the link:
subject: NoClassDefFoundError
It's not a secret anymore!