• 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

classpath

 
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
classfiles
Chapter10/bin/com/bui
Chapter10/bin/com/wip

source

Chapter10/src/com/bui/B.java
Chapter10/src/com/wip/Hello1.java

This is my package structure.





I am using windows. Hello1.java is using B. I compiled B. B.class is in bin/com/bui. Now I to compile Hello1.java I used the following command line. current Directory is Chapter10.

javac -d bin -classpath bin\com\bui src\com\wip\Hello1.java

it's not compiling .showing errors com.bui doesn't exist. And it compiled fine with the following.

javac -d bin -classpath bin src\com\wip\Hello1.java

I didn't understand why it is not compiling in the first case.

And also in the 10th Chapter K&B book I didn't get the following point. Anyone please expain......

Remember when using a classpath, the last directory in the path must be the
super-directory of the root directory for the package.

 
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Remember when using a classpath, the last directory in the path must be the
super-directory of the root directory for the package.



this means

if your class A is



and class B is



and suppose your A.class file is here:

bin/p1/packagea/A.class



then p1 is the root-directory for the package p1.packagea;
and bin is the super directory of p1 package's root-directory.

So in your classpath bin should be last directory.
suppose your dir structure is:

project/bin/p1/package1/A.class
project/p2/B.java


and you are in project directory then you need to give bin in classpath while compiling B.java



 
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Banu Chowdary wrote:I didn't understand why it is not compiling in the first case.



Answer to this question is here
Hope it is helpful
 
reply
    Bookmark Topic Watch Topic
  • New Topic