• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K and B Chapter 10 pg no 802

 
kiruthigha rajan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
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
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic