I use Runtime.exec to execute an exe, normally when this exe runs under dos command it runs rather quickly. However running it from java seems to slow it down considerably(maybe 100x). I am wondering if this is because java allocates limited resources to run the exe. If so what's the solution to make it run quicker. thanks
The executable is presumably native code, so its execution is not influenced by Java memory constraints or JVM speed - it's its own process with its own memory. How do your measure the speed?
Joined: Sep 16, 2004
I guess what Ulf Dittmer saying is right.
It should not be make any difference.
I believe, if you run application from Java, it may take more time to startup compare to the directly startup. But it should not slowdown overall performance. [ September 30, 2005: Message edited by: Chetan Parekh ]
Are you reading the output streams from the process? I wonder if the exe could hang trying to write stdout or errout. Some won't run at all if you're not reading the streams.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Apr 07, 2004
I am reading the standard outputstream and output error stream. The exe writes to a status file once every second to indicate how much has been done. that's how I know that the exe process slowed down not just by the startup time but actually along the way. The exe took 10 secs when running from the dos cmd, and took 100 secs when running from java. If jvm does not put any memory/resource constraint on the native process it spawned, then i am guessing that by reading from standard output and standard error, the java app interfered when the normal native execution? thanks for any helpful advise