File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Associate Certification (SCJA/OCAJ) and the fly likes java -classpath option Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Associate Certification (SCJA/OCAJ)
Reply Bookmark "java -classpath option" Watch "java -classpath option" New topic
Author

java -classpath option

Beny Na
Ranch Hand

Joined: May 26, 2004
Posts: 159
hi all,

could anyone of you give me an example how to use
javac -classpath


i don;t know how to use it

pls help

thanks
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Beny,

Assuming myjar.jar is in c:\jardir and Engine.class in c:\classdir, and those files are needed in order for Car.java to compile successfully. So you use "classpath" option to tell the compiler where to look for those files. Car.java is stored in c:\workarea directory.



For Windows, use semicolons to separate the classpath as shown in the example above; for Solaris, use colons. For more info, see Windows: classpath and Solaris: classpath.

There are some rules you need to follow when setting the classpath.
Quote from Solaris: classpath (same for Windows):
  • For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file.
  • For .class files in an unnamed package, the class path ends with the directory that contains the .class files.
  • For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).

  • Joyce
    [ July 14, 2005: Message edited by: Joyce Lee ]
    Beny Na
    Ranch Hand

    Joined: May 26, 2004
    Posts: 159
    Nice Reply...

    thanks a lot Joyce
     
     
    subject: java -classpath option
     
    Threads others viewed
    Writing First JavaMail program
    UnMarshalException - Nested ClassNotFoundException again
    How to set class path during compilation
    NoClassDefFoundError
    Exception in thread main
    MyEclipse, The Clear Choice