Is there any way to avoid the delay caused by the JVM starting up each time you run an exec command in PHP?
I have two JARs for encryption and decryption that I need to run using PHP. Both run on the same script although one decrypts a URL parameter and then the other encrypts some other information. When I run them through the command line, they both finish in less than 0.4 seconds each. However, when I run them using the PHP exec function, a new instance of the JVM is started which adds 5 seconds onto each JAR execution time.
I have investigated using Nailgun but can't get that to work. I can't find any documentation for getting it to run a JAR and when I use classes, it can never find them either.
I have also considered using PHP/Java Bridge. I would prefer however to continue using exec. I am already running IIS 7.5 and I am not sure how one would configure the bridge to work with this.
My question is this:
Is there any way to keep the JVM running in the background in such a way that the PHP exec function does not need to start a new instance each time? I think there must be a way as there is no delay through the command line.
If there is no way of doing this, then I am open to other suggestions. 11 seconds to run a PHP script means that visitors to the website will most likely leave.
Additional information that may or may not be of use:
It will be running on Windows Server 2008 R2 32-bit OS.
Local access required only.
IIS server 7.5 being used.
Website is coded in PHP. PHP version is 5.3.5.
Server is running the latest JRE - Java7 u6