I have a sourcecode and in this source
are two classes
referenced.
Now I want to compile
this code via JavaCompiler
but therefore I have to first compile the two referenced classes
.
Is there a better method than reading the file and search for the classes, to compile them first?
package data.testcases
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
XTest.class,
YTest.class
})
public class ASuite {
}
XTest.java and YTest.java are in the same dir as Suite is
Now I want to compile this code via JavaCompiler but therefore I have to first compile the two referenced classes
No you don't. As long as the Java compiler can find those classes it will compile them automatically. That means that they need to be located in the same directory system as the file you are actually compiling, or else locatable via the -sourcepath option.