• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Problem starting .bat file from java code on windows 2003

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to start some bat file from java code. On almost the same server (windows 2003 64 bit) which is STAGING environment, everything works fine, but on the Production environment, bat file is simple not started. Anybody has any idea (running out of it)?

Here is the code:


try {
log.info("Calling external command: ");
Process proc = Runtime.getRuntime().exec("cmd /C start D:\\start.bat");
proc.waitFor();
} catch (Exception e) {
log.error("Error:", e);
}

No exception is thrown.
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search for and read the Javaworld article "When Runtime.exec() won't". It will explain why Process.waitFor can (and often will) block.
I had a problem once with an external process blocking, and after reading this article the problem was solved in minutes.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It looks like the process did not complete yet?!
Perhaps you'll find an answer here.

Otherwise, you should also share with us the content of batch file ...


Regards,
Rok
 
Ivica Boskovic
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is executed, since when I put something like
log.info("...");

at the end, it is executed. I saw cmd in the list of windows processes.

It is always the same, no metter of the content of the bat file,
for example xcopy....

on staging environment works, on production no...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!