File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic
Author

NoClassDefFoundError

ShivaK Thadakamadla
Greenhorn

Joined: May 21, 2003
Posts: 4
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

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
Greenhorn

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 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.


http://www.mcgath.com/consulting/
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: http://aspose.com/file-tools
 
subject: NoClassDefFoundError
 
Similar Threads
JIT....?
how to trace jvm loading class info.
Is JDK same for all platforms(windows,unix,mac) or is it different for different operating systems.
running HelloWorld
SCJP 5 Study Guide: Self Test Q. 12 - Page 788