aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Absolute classpaths 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 "Absolute classpaths" Watch "Absolute classpaths" New topic
Author

Absolute classpaths

richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
Question: if I have a class defined in
mycomputername:/~/Documents/Java/myProject/source/Another.class
and I want to invoke it using an absolute classpath, what should my classpath include? I've tried
java -classpath /Documents/Java/myProject Another

and
java -classpath /Documents/Java/myProject/source Another

and
java -classpath /~/Documents/Java/myProject Another

as well as
java -classpath /~/Documents/Java/myProject/source Another

and keep getting NoClassDefFoundErrors. I would have thought that one of these paths would have worked.
narendra bhattacharya
Ranch Hand

Joined: Feb 17, 2010
Posts: 66
you are using windows or linux..


SCJP1.6,SCWCD1.5
richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
Actually, OSX.
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
See my reponse in your other post


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
narendra bhattacharya
Ranch Hand

Joined: Feb 17, 2010
Posts: 66
in linux based os... / is the root directory but on OSX i don't know...
in windows we have to with write with full path like c:/pro....
richard rehl
Ranch Hand

Joined: May 21, 2007
Posts: 36
narendra bhattacharya wrote:in linux based os... / is the root directory but on OSX i don't know...
in windows we have to with write with full path like c:/pro....

Thanks, figured it out, one thing I hadn't tried - has to start with the tilde "~" character instead of the forward slash, so:
java -cp ~/Documents/Java/myProject/classes MyClass
Is this different than Unix or Linux convention?
 
Consider Paul's rocket mass heater.
 
subject: Absolute classpaths