Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Mar 1997 22:16:06 -0700 (MST)
From:      Nate Williams <nate@mt.sri.com>
To:        John Fieber <jfieber@indiana.edu>
Cc:        Nate Williams <nate@mt.sri.com>, freebsd-hackers@freebsd.org
Subject:   Re: Java awt support?
Message-ID:  <199703060516.WAA11418@rocky.mt.sri.com>
In-Reply-To: <Pine.BSF.3.95q.970306000832.1845C-100000@fallout.campusview.indiana.edu>
References:  <199703060154.SAA10410@rocky.mt.sri.com> <Pine.BSF.3.95q.970306000832.1845C-100000@fallout.campusview.indiana.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
> > I know of at least 2 bugs in it.
> > 
> > - You can't use call system executables from it (it blows chunks and
> >   leaves the process you called running in the netherlands).
> 
> Really?  Could you send a snippet of code that exercises this?


Sure, here you go.  Replace the command with anything you feel like.


Nate
--------------
import java.io.*;

public class Exec {
  public static void main(String[] argv) {
    String cmd = "/sbin/ping www.symantec.com";

    try {
      Process process = Runtime.getRuntime().exec(cmd);
      String line;
      DataInputStream dis = new DataInputStream(process.getInputStream());

      while ((line = dis.readLine()) != null) {
        System.out.println(line);
      }

      System.out.println("Exit value was: " + process.exitValue());
    } catch(IOException ioe) {
      System.err.println(ioe + " IO Error executing command: " + cmd);
    }
  }
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703060516.WAA11418>