• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classpath K&B problem

 
Akanksha Joy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Source: SCJP K&B

I have not understood why we cannot move to xcom folder and access A.class file there. The fully qualified name of the A.class file is 'xcom.A' and B want to have access to A.class thats y? What about the other parts......Please explain with reason...
 
Alexander Danilou
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Important point to remember that classpath should point to super-directory of the package (please see K%B 6 page 804 last paragraph). So, you should be either in super-directory, or test in this case, OR you can also use absolute path, but this option is not provided here.
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well since the fully qualified name of the class is xcom.A, so you must access it from the parent directory of xcom (or the parent directory must be in the classpath). If you try to access A from xcom directory, then it will try to find a folder named xcom in the xcom directory and it will not be found.

So the deal is, if the package ab.cd has a class MyClass and you have this directory structure folder/ab/cd, then you must move to folder directory and use ab.cd.MyClass to access the class. You cannot access MyClass if you move to ab directory or cd directory...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This exact same question has been discussed more than once before. Try searching the forums for "xcom" and you'll find the older discussions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic