You cannot add a single class file as such, you add a directory to the class path, and the compiler will search for classes in this directory by relative paths obtained from their package structure. This, to my knowledge, is not negotiable. The directory structure must match the package structure.
So, for example, if the class defined in SomePOJO.class is stragglers.SomePOJO , you must add the gen directory to the classpath
<javac includeantruntime="false" srcdir="src/main/java" destdir="gen/bin/main"> <classpath> <pathelement location="gen" /> <path refid="main.compile.path"/> </classpath> </javac>
If the path to the .class file does not match the package declaration of the class, then you will have to move it to a temporary directory that matches the package structure, and then add this directory to the classpath.
source share