• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javac Command

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javac -classpath /tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/QuoteServlet.java

Could any one please explain me what the :classes:. signify?

Thanks in advance.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Entries in the "classpath" represent *.jar files or directories. In your example, "classes" appears to be a subdirectory of the working directory. Javac will search for class files there, and the new files it produces will be placed there (because of the "-d" switch.)
 
Chandu Neni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for ur instant reply.

I am not still clear about it.

javac -classpath /tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/QuoteServlet.java

In the above command "-classpath /tomcat/common/lib/servlet-api.jar:classes:. ", does it mean the javac will look for classes in servlet-api.jar and also classes dir in .(current dir)
What does :classes:. notation exactly mean?

Thanks in advance.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The : is a separator between different parts of the path. ':' is the path separator on Unix systems, while for Windows it would be ';'. Anyway, with a classpath of

/tomcat/common/lib/servlet-api.jar:classes:.

that splits into three parts, separated by ':'.
  • /tomcat/common/lib/servlet-api.jar
  • classes
  • .
  • What that means is, when javac needs to find a particular class, first it will search the servlet-api.jar, then it will search the classes directory, and then it will search the current directory. (Because '.' is a special symbol for the current directory.)
     
    Chandu Neni
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Jim,

    Its crystal clear now. Didnt know : is a seperator in Unix like ; is in windows.

    Need a little more clarification on javac -classpath..

    if there is a environment variable classpath set, will javac look for the classes both in the classpath set in the environment variable and also given as a flag (-classpath) in the command or does it only look in the flag and ignore environment variable.

    Thanks a lot.
     
    Jim Yingst
    Wanderer
    Posts: 18671
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If the -cp or -classpath options are used, any CLASSPATH environment variable is ignored. The place to find this info is in the javac and java documentation, found under tools and utilities in the JDK documentation.
     
    Chandu Neni
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks once again Jim.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic