• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

process has not exited

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am using Runtime class in my application.It creates JAR & EAR Files.For that I used Runtime class.
Here my peace of code Pls help me what is worng in this code.


try {
String stmt = "jar -Mcvf " + ejbJarName + " META-INF/MANIFEST.MF " +" META-INF/ejb-jar.xml " + " com";
Process stmtProcess = java.lang.Runtime.getRuntime().exec(stmt);
if (osname.startsWith("Windows")) {
System.out.println("use Thread.sleep(" + ntdepltime + ")");
Thread.sleep(100000);
try
{
stmtProcess.exitValue();
}catch(IllegalThreadStateException exp){ System.out.println("Madhu exception "+exp); }
} else {
System.out.println("use waitFor()");
stmtProcess.waitFor();
}
stmt = "jar -Mcvf " + newEarName + " META-INF/MANIFEST.MF " +" META-INF/application.xml " + ejbJarName + " " + clientJarName;
stmtProcess = java.lang.Runtime.getRuntime().exec(stmt);
if (osname.startsWith("Windows")) {
System.out.println("use Thread.sleep(" + ntdepltime + ")");
Thread.sleep(100000);
} else {
System.out.println("use waitFor()");
stmtProcess.waitFor();
}
} catch (Exception e) {
e.printStackTrace();
}

After JAR file creatation execution it is throwing java.lang.IllegalThreadStateException exception.

Pls help me in this regard.

thanks,
Madhu
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put your sleep in a synchronized block as shown in THIS thread.

I'm curious why you don't trust waitFor in Windows. Are there known issues with that?

You might also search this thread for StreamGobbler. There were some good examples of reading stdout and errout from the process. I only did all this stuff once and I waited for the outputs to end rather than using waitFor(). The streams seemed to run a while after waitFor returned, maybe because they were buffered or something.
 
You don't like waffles? Well, do you like this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic