• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

classpath K&B problem

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Get off me! Here, read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic