I have two packages named Schedule and Debt. In Schedule package , we import the Debt package. In Debt package , we import the Schedule package. I wish to know how to compile these two interrelated packages
Thanks in advance
You should have directories that reflect your package names; something like this:
- you/java/src/Debt/DebtClass.java
- you/java/src/Schedule/ScheduleClass.java
- you/java/classes
move to the src directory and compile your .java files like this:
javac -cp ../classes -d ../classes -sourcepath . Debt/*.java Schedule/*.java
The -d flag tells the compiler where to put the compiled .class files. the -cp
path tells the compiler where to find previously compiled .class files. the
-sourcepath flag tells the compiler where to find other source (.java) files if
it needs them, i.e. a .java file refers to another class but it hasn't been compiled
yet (or is outdated) so the source of that other class needs to be recompiled.
Note that you end up with .class files like this:
- you/java/classes/Debt/DebtClass.class
- you/java/classes/Schedule/ScheduleClass.class
which is exactly what you need because you can add an entry to your classpath
starting at that classes directory.
kind regards,
Jos