File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes process has not exited Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "process has not exited" Watch "process has not exited" New topic

process has not exited

Madhu Bala

Joined: Jul 30, 2002
Posts: 8
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 + ")");
}catch(IllegalThreadStateException exp){ System.out.println("Madhu exception "+exp); }
} else {
System.out.println("use 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 + ")");
} else {
System.out.println("use waitFor()");
} catch (Exception e) {

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

Pls help me in this regard.


madhu babu
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.

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
I agree. Here's the link:
subject: process has not exited
It's not a secret anymore!