• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

running exe from java

 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am not wrong, then when you run any application via java, JVM / JRE also comes in the picture. Hence it doesn't run as fast as it runs directly.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic