Method which is being used:
public void execute()throws RuntimeException, SecurityException, IOException
{
Process p = Runtime.getRuntime().exec(command);
InputStream er = p.getErrorStream();
BufferedReader os = new BufferedReader( new InputStreamReader(p.getInputStream()) );
String output = "";
while((output = os.readLine())!=null)
{
System.out.println( os );
messages.setText(output+'\n');
}
String erronous = "";
BufferedReader ir = new BufferedReader( new InputStreamReader( er ) );
if( ir == null )
return;
while((erronous = ir.readLine())!=null)
{
errors.setText(erronous+'\n');
}
}
The program throws an error at the very first line of the method.
Any suggestions
--Karl.
Yes, it's not in your code, but I suppose you are passing "dir" as command.
"dir" is not a executable program on Windows, but part of the command.com
program. Try "command.com /c dir" as argument, this is supposed to do the
trick, or try something that IS a program ("tree" is, as far as I know).
Philip
: --Karl.
This doesn´t work because dir is a internal dos command (i.e.
not found in the path).
You should do it like this instead (I think one the commands below
works for Win95 and the other for WinNT):
Process p = Runtime.getRuntime().exec("command /c dir");
Process p = Runtime.getRuntime().exec("cmd /c dir");
If you want more info check out Java Developer Connection. There has been some questions and bug reports dealing with exec() and Win95.
Hope this helps you!
/Peter
Karl Lopes wrote:
InputStream er = p.getErrorStream();
}
--Karl.
Runtime rt = Runtime.getRuntime();
Process child = rt.exec ("dir");
try {
System.err.println("Return status from call is " +
child.waitFor());
DataInputStream in = new DataInputStream(new
BufferedInputStream(child.getInputStream()));
while (in.available() > 0) {
System.out.println(in.read());
}
===
--
<------------------------------------------->
Allan Wax
e-mail: Alla...@jpl.nasa.gov
FAX: + (213) 935-9292
NOTE: The views expressed in this message are
my own and do not necessarily reflect
those of my employer.