Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

How to get the status of the runtime process in java..?

Thread view: 
janak - 09 Aug 2006 05:35 GMT
Hi,
I am trying to execute a System command located at remote machine.So i
use Rmi concept for this purpose.

The model source code is
try
{
Runtime r = Runtime.getRuntime();
Process p = r.exec("System command");
int e = p.waitFor();
System.out.println("The process value :" + e);
}

catch
{
...}

I got succeed in executing the file.here waitFor() method will return a
value 0 (if the process executed successfully) or 1 (if the process
execution fails)But the problem i faced is i cant able to get the
status of that execution whether it is running or get terminates. The
waitFor() method work successfully on the terminal(or command window in
windows)when i terminate the process by using ^C but when i tried this
in JSP i cant able to terminate the process.  I tried to use the
exitValue() method but i cant. How to monitor the runtime process on
remote machine. I am using Linux and Netbeans IDE.

Can anyone give solution to this.....

S.Janakiraman
Thomas Fritsch - 09 Aug 2006 12:29 GMT
janak schrieb:
> The model source code is
> try
[quoted text clipped - 20 lines]
>
> Can anyone give solution to this.....
According to the API doc at
<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Process.html#exitValue()>
you could do

  public static boolean isRunning(Process process) {
    try {
      process.exitValue();
      return false;
    } catch(IllegalThreadStateException e) {
      return true;
    }
  }

Signature

Thomas



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.