Working on an application which requires several source files(.java) to be compiled and corresponding class files(.class) to be generated at runtime and this happens at application start-up.
Currently using below code for class generation:
int errorCode = com.sun.tools.javac.Main.compile(new String[] {
"-cp", classPath,
"-d", pOutputPath,
srcFile.getAbsolutePath() },new PrintWriter(out));
Every *.java file is hardly some 40 lines of code with a single method. But the time the above given code takes to compile is around 2 seconds per file.
Application has more than 1000 or sometimes 2000 java files. So application start up time is more than 2000 or 4000 seconds which is undesirable.
Any alternative for com.sun.tools.javac.Main.compile
?
Or a better or faster way for runtime compilation and class file generation?
I can't use multi-threading as the environment is single-threaded.