*
http://kingj.iteye.com/blog/1420586
, there was
Java.lang.IllegalThreadStateException:process have not exited
At Java.lang.Win32Process.exitValue (Native Method)
Exception, background 100 degree discovery, the JDK implementation process, call External command is not synchronous call, but asynchronous execution. So the tree command returns without executing successfully, and the JDK throws an exception.
int Status=process.exitvalue ();
My solution is to use Thread.Sleep (1000) in front of this sentence;
Or
The reason is that the Exitvalue () method does not wait for the external process to end. If the external process is not finished, Exitvalue () will throw illegalthreadstateexception. The solution is to call the process's waitfor () method. The WAITFOR () method suspends the current thread until the external process finishes. Of course, using Exitvalue () or waitfor () depends entirely on your needs. You can set a Boolean flag to determine which one to use. Run the following code:
*
Java call Shell process has not exited