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

Stupid classpath question

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have done fbn_srv.jar and fbn_cli.jar. They work ok if I run them from the same directory:
java -jar fbn_srv.jar db.db 1099
I have tried to get this work from any directory. I have tried this:
java -classpath c:\ -jar fbn_srv.jar db.db 1099
but I get ZipException (= cannot find the jar file).
Should I edit the operating system's classpath or is it more reasonable to use only -classpath option? I think the latter would be nicer but how to do it?
Any help appreciated. Thank you.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

java -classpath c:\ -jar fbn_srv.jar db.db 1099

The "-classpath" option is ignored when you use a "-jar" option.
[ November 11, 2002: Message edited by: Eugene Kononov ]
Trish Wu
Ranch Hand

Joined: Oct 09, 2002
Posts: 34
I think it is not a bad idea to specify classpath and main class in the Manifest file.
Sun tutorial Jar
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thank you for your answers.
I had specified the Main classes in Now I tried defining class paths in the jar file that contains server and client jar file. It worked in my computer with Win2000 but not in test computer with only JRE in Win NT.
Is that enough if I give just two command lines that the user should use?
>java -classpath /mypath/fbn_srv.jar suncertify.rmi.RMIServer /mypath/db.db 1099
>java -classpath /mypath/fbn_cli.jar suncertify.flybynight.Main ip 1099
OR another way
>java -jar /mypath/fbn_srv.jar /mypath/db.db 1099
>java -jar /mypath/fbn_cli.jar ip 1099
These should work from any directory.
I agree. Here's the link:
subject: Stupid classpath question
It's not a secret anymore!