File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Facing problem to set classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Facing problem to set classpath" Watch "Facing problem to set classpath" New topic

Facing problem to set classpath

Deepak Bobal
Ranch Hand

Joined: Feb 06, 2008
Posts: 96
I have a class file named add.class in deepak folder
full path is c---deepak----add.class
Now what i am doing
c:\>java -classpath c:\deepak\
So rather than getting set the class path it's showing me a long list of USAGES and help options.
My java file is in "bin" folder
Am i doing wrong?
How can i make it run using -classpath SDK option?

Constant dripping hollows out a stone....
Deepak Chopra
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

you forgot to give the exact class name..which class you want to run:
try this

c:\java -classpath c:\deepak\ add


c:\java -classpath /deepak add
[ February 19, 2008: Message edited by: Sunny Jain ]

Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
Deepak Bobal
Ranch Hand

Joined: Feb 06, 2008
Posts: 96
Thanks Sunny for your quick response
But still file is not getting run.
I am mentioning full procedure what i have done

class add1
int a,b;
void add(int i,int j)
System.out.println("addition is "+a);
public class add
public static void main(String arg[])
add1 o=new add1();


above mentioning code i kept in c---jdk1.5.0--bin
then C:...bin>javac
i got two class files add.class and add1.class

i cut them from that location and in pasted in c--deepak

now comin back to root means at c drive
C:>java -classpath c:\deepak\add

but it's not setting classpath,its showing help options.
and i tried second option also as you have suggested.
But not getting.
Please tell me where am i wrong???
Deepak Bobal
Ranch Hand

Joined: Feb 06, 2008
Posts: 96
I got myself where i was wrong
using C:\>java -classpath c:\deepak add
I got it run.
I agree. Here's the link:
subject: Facing problem to set classpath
It's not a secret anymore!