• 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

Question on Classpaths

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All contents are taken from Kathy and Bert's SCJP Book.


Given this file directory :




A Classpath :



States:
Remember when using a classpath, the last directory in the path must be the
super-directory of the root directory for the package. (In the preceding example, myApp is the root directory of the package myApp.utils.) Notice that myApp can be the root directory for more than one package (myApp.utils and myApp.engine), and the java and javac commands can find what they need across multiple peer packages like this. In other words, if ws is on the classpath and ws is the super-directory of myApp, then classes in both the myApp.utils and myApp.engine packages will be found.


Why did -classpath ws search directories utils and engine? I thought it'll only search for all .class files in the directory instead. Why in this case, -classpath ws would search for all of it's sub-directories? I dont really understand what's a super directory but I think I know it's linked to a root directory.


Hope to get feedback! Thanks.
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.javaranch.com/name.jsp
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javac -classpath ws Util.java

Will only search for directory ws and not any subdirectory.
What the book text is saying is that it can search in the subdirectories also but for that you will hav to specify the location i.e

javac -classpath ws myapp.utilUtil.java

Super Directory for the root directory is the directory from where the package is directly accessible as specified in the javac command.

for example ws is the super directory from where javac can directly locate myapp/util directories
 
reply
    Bookmark Topic Watch Topic
  • New Topic