aspose file tools*
The moose likes Beginning Java and the fly likes Help on java classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help on java classpath" Watch "Help on java classpath" New topic
Author

Help on java classpath

Paolo Dina
Ranch Hand

Joined: Aug 15, 2008
Posts: 63
I have this code:



And this class: Development/Java/net/mindview/util/Print.class. CLASSPATH envvar has the value Development/Java.

With this setting I'm able to compile with success Print.java typing javac Print.java. I would expect to use the same syntax to run java, instead I have to type java -cp . evelopment/Java Print or I get is this error:

Exception in thread "main" java.lang.NoClassDefFoundError: Print

At this point, I'd like to know why in the latter case I have to specify a classpath (even if CLASSPATH variable already contains the right path), while javac doesn't require this?

Thanks
[ December 26, 2008: Message edited by: Paolo Dina ]

SCJP 5
Paolo Dina
Ranch Hand

Joined: Aug 15, 2008
Posts: 63
And this class: Development/Java/net/mindview/util/Print.class. CLASSPATH envvar has the value Development/Java.


Just found by myself, sorry... it was that CLASSPATH should include the current directory also!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
Originally posted by Paolo Dina:


Just found by myself, sorry... it was that CLASSPATH should include the current directory also!


No need to be sorry; well done working it out, and thank you for posting the solution to help other readers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help on java classpath