Possible Duplicate:
How to speed up Java VM (JVM) startup time?
Over the course of the day, I have to execute a series of small & quick Java command line programs. On Windows, to run a simple Java program from a the command line (like Hello World), sometimes it takes around 5 seconds due to the overhead of launching the java.exe process. The programs take a second to execute but the overhead of starting the programs is dominates the total execution time. Is there a way to optimize this?
Is there something like a Java shell that I can use to execute programs in-process? Similar to the Python shell?
This may be overkill, but you could set up an application server like Tomcat or Glassfish and run your programs within the server. From what I understand, one of the original purposes of Java Servlets was to eliminate the startup dely associated with traditional CGI programs.
I don't know much about Java, so I don't know if there are simpler solutions available. But Tomcat et al are already available, so you wouldn't need to write your own server program.
Edit: someone else pointed out a similar question, How to speed up Java VM (JVM) startup time? One of the answers to that question mentions Nailgun, which looks like a near-perfect solution to your problem.
You might write your own shell. You can write a single command line program that embeds all the functionality of those "utilities". You launch it, you keep it running and then you make your queries via some syntax you decide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With