views:

40

answers:

2

My structure looks like this

\Project1 
  \src
    \pkg1
      Main.java
    \pkg2
      Auxillary.java
  \Destination
    \class
    \lib

I need to compile Main.java which has dependencies in Auxillary.java and jars in \lib into \Destination\class

I am in the Project1 directory.

I tried

javac -cp Destination\lib\*;src\pkg2\* -d Destination\class

However, I get a package not found for Auxillary.java.

What am I doing wrong?

+2  A: 

A classpath entry can't refer to a source directory. Try this:

javac -Djava.ext.dirs=Destination\lib -d Destination\class
      src\pkg1\Main.java src\pkg2\Auxiliary.java

i.e. compile all the source code in one go. Alternatively:

javac -Djava.ext.dirs=Destination\lib -d Destination\class
      src\pkg2\Auxiliary.java

javac -Djava.ext.dirs=Destination\lib -cp Destination\class
      -d Destination\class src\pkg1\Main.java

That will compile Auxiliary.java first, and then use its destination directory as part of the classpath when compiling Main.java.

Jon Skeet
A: 

Hi kunjaan, You can use ant script to make these steps simpler. Try once!

Nikesh PL