Jewels
Jewels

Reputation: 1036

JavaCompiler API - slow compilation when running in tomcat

My application generates java code during runtime and compiles it using the JavaCompiler API. Some of the generated files can be rather large - up to a few hundred thousand lines. I find that when I run the javac command on the generated code in the command line, or alternatively if I use an application that does just the compilation via the JavaCompiler API, I can compile many of these files (~500), even if they are very large, in under two minutes. However, if I call the API via my application when it is running on a Tomcat server, the compilation time runs upwards of twelve minutes (!!!).

I would appreciate any suggestions on how to improve the performance of the compilation.

Thanks!

Upvotes: 9

Views: 422

Answers (1)

volatile
volatile

Reputation: 179

Try to set the thread priority to the highest value (on the thread or thread pool):

setPriority(Thread.MAX_PRIORITY);

Upvotes: 1

Related Questions