IntelliJ Java IDE
The moose likes Java in General and the fly likes java.lang.Process process.exitValue() return 9 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "java.lang.Process process.exitValue() return 9" Watch "java.lang.Process process.exitValue() return 9" New topic
Author

java.lang.Process process.exitValue() return 9

madhusudhanan anna
Greenhorn

Joined: Nov 08, 2010
Posts: 4
Hi,

While i am executing the following code, i am getting the exitvalue as 9 instead of 0.

Process process = null;
InputStream inStream = null;
try {
process = Runtime.getRuntime().exec(command);
process.waitFor();
int exitValue = process.exitValue();
log.debug("Process has exited (exit value={})", exitValue);

}.....

I am getting the exitValue as 9 instead of 0. Can any one help me on this.

If i comment the process.waitFor(); line, the system throws InterruptedException.


Thanks
Madhu
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26720
Surely the 9 depends on which program you are invoking?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3133
madhusudhanan anna wrote:
While i am executing the following code, i am getting the exitvalue as 9 instead of 0.


Then that is the exit value of the command. You need to look into that command's documentation and find out what its exit codes mean and what might cause it to return 9.
madhusudhanan anna
Greenhorn

Joined: Nov 08, 2010
Posts: 4
Hi

My environment is Sun Solaris X86.

If i execute this code in a standalone program it works fine.

If i put the above code in my project and run in the glassfish server, i am getting this error.

Thanks
Madhu
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3133
madhusudhanan anna wrote:Hi

My environment is Sun Solaris X86.

If i execute this code in a standalone program it works fine.

If i put the above code in my project and run in the glassfish server, i am getting this error.

Thanks
Madhu


You need to look into that command's documentation and find out what its exit codes mean and what might cause it to return 9.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26720
Nor can I, but shall we get back to the official subject of this thread?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3133
Campbell Ritchie wrote:shall we get back to the official subject of this thread?


Not sure what else there is to be said at this point. All we know is that some unknown process runs fine from a standalone but gives exit code 9 in glassfish. I think the ball is in the OP's court now.
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18370

I've removed a few posts that were going off topic, as I feel that madhusudhanan anna's issue isn't resolved yet. Moving this thread to MD would probably mean the issue would never be resolved, and that's not what the Ranch is about.

Speaking of the original issue, madhusudhanan anna, can you tell us what the value of command is? Perhaps you've included some shell operators; java.lang.Process can't handle those itself.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
 
subject: java.lang.Process process.exitValue() return 9
 
Threads others viewed
How to ensure a file is written completely.
exitValue returns inconsistent values.
Runtime.exec to wait for external application
Why is not the process terminating after executing the command
using Runtime.exec() and the process exitValue = 1
developer file tools