File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K and B Chapter 10 pg no 802 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K and B Chapter 10 pg no 802" Watch "K and B Chapter 10 pg no 802" New topic

K and B Chapter 10 pg no 802

kiruthigha rajan
Ranch Hand

Joined: Dec 29, 2011
Posts: 69
i am having some doubts in the following cp..

1) -cp /dirB:/dirA/dirB/dirC

here the directories are searched from root as the / indicates..
my question is what directories will be searched if the current directory is dirA?
the answer given in book is only dirC but how??directory B will also be searched when DirA is treated as current directory

2)"It doesn't matter what the current directory is; since absolute paths are specified the search results will always be the same."
im unable to understand the meaning of this line

thanks in advance
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924

to understand this you need to understand the concept of Absoute Path and Relative path. Absolute path starts from the root of the file system. if the file system is Unix/Linux , it is the root folder which is represents as single forward slash /. in case of windows based system root of the file system will be root drive for eg. c:\ or D:\. Relative path means "relative" to the current working directory. in your example the classpath is given as /dirB:/dirA/dirB/dirC. since the path starts from / it is absolute path. now if you consider the directory structure given in book , it says that root folder(/) contains dirA, which contains dirB, which further contains dirC. so /dirB means that "a directory by the name dirB in root folder (/) " which obviously is not there. then it will look at /dirA/dirB/dirC, which means starting from root folder, then dirA, inside dirA there should be dirB and then dirC. so it will look for classes in dirC.

second part of your question is also summed up in the above paragraph. since the paths are absolute, no matter in which directory you are , you will always start from the root directory(/). so current working directory doesn't matter.

I hope you are clear.
I agree. Here's the link:
subject: K and B Chapter 10 pg no 802
jQuery in Action, 3rd edition