I have a Java project,Parent, which depends on a Child sub-project (in the form of a JAR). This Child depends on library A and B and those get bundled in with Child. Parent uses Aand B as well (meaning direct calls, not indirect through Child. I want to be able to include A and B JARs only once in my project.
When I am compiling Parent, I get a cannot find symbol when it references libraries A and B. I believe this is because Child is on the compile time path, but for some reason the libraries within it are not.
I am using ant as my building tool – is there anything special I should be doing in my javac tags for nested jars? Right now in Parent‘s build.xml I have:
<target name="compile" depends="clean, makedir">
<javac
srcdir="${src.dir}"
destdir="${build.dir}"
includeantruntime="false"
classpathref="build.classpath">
</javac>
</target>
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
This should be including all of the jars present in my lib folder, but it doesn’t seem to include all of the jars within jars.
My problem stemmed from the fact that Java cannot natively reference jars inside of jars. You’ll need to use something like http://one-jar.sourceforge.net/ to get around it.