How can I get javac to find child classpaths?

I have 3 files: /a/A.java /a/aa/AA.java /b/B.java and B.java depends on A.java and AA.java.

Basically I want javac -classpath / a / b / B. java to work (i.e. has javac search below / a). Is there a way to do this?

0


source to share


1 answer


The short answer is no, this is not how class directories work.

Each pathpath is considered the root of the package structure. Each package is a directory at the root. So javac will do it automatically if aa is the packages directory and a is the root. You will look like this:

/a/A.java

class A {}

      

/a/aa/AA.java



package aa;
class AA {}

      

/b/B.java

package b;
import aa.AA;

class B {
  private AA aaInstance;
  private A aInstance;
}

      

Since A has no package, it is placed in the root package.

Otherwise, you need to set each dir explicitly.

+3


source







All Articles