• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java -classpath option

 
Beny Na
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 159
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nice Reply...

    thanks a lot Joyce
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic