File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Absolute classpaths

 
richard rehl
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are using windows or linux..
 
richard rehl
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, OSX.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See my reponse in your other post
 
narendra bhattacharya
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic