wood burning stoves 2.0*
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
Author

Need to Set Classpath

Lavesh saxena
Greenhorn

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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Here is a good place to start.


[My Blog]
All roads lead to JavaRanch
Lavesh saxena
Greenhorn

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\Example.java

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

SCJP 6
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
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Closing thread as duplicate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to Set Classpath
 
Similar Threads
running java program out of workspace
javac not recognized
I Can't Run any Java Programs!
doubt in protected access
Need a fix for the error