File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Need to Set Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Need to Set Classpath

Lavesh saxena

Joined: Oct 11, 2008
Posts: 15
Can anybody please tell me how to set Classpath. where do we need to set this path...

As i am getting error during execute the program. there is no error in compilation...

"Exception in thread "main" java.lang.Noclassdeffounderror"

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Here is a good place to start.

[My Blog]
All roads lead to JavaRanch
Lavesh saxena

Joined: Oct 11, 2008
Posts: 15
Actually i didn't get this point...

As i have made one program & save in my path "D:\Java_Programs\"....

After that i compiled my program as below.

C:\ javac D:\Java_Programs\

after that there was no error then execute my program

C:\ java D:\Java_Programs\Example

so i got errors. its mention below

"Exception in thread "main" java.lang.Noclassdeffounderror".

Can you please help to rectify above error.

James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

If you have set the CLASSPATH to \Java_Programs\
then the below will work
C:\ java Example

or try this..
C:\ java -cp D:\java_programs Example

Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
Preet Prasannan.
Ranch Hand

Joined: Feb 09, 2009
Posts: 64
I guess the best way would be .
Go the command prompt
C:\ set classpath=<path of lib folder in your jdk ex. C:\Proram FIles\j2sdk 1.4.2\lib>;.;
The ;.; makes sure your this apth gets concanated to your existing class path.
ALso set the path in the same way but make it to pint to bin folder of jdk.
Hope it helps :-)

"The more I learn,the more,I get to know, is left to learn."
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
Closing thread as duplicate.
I agree. Here's the link:
subject: Need to Set Classpath
It's not a secret anymore!