Article View: comp.lang.java.programmer
Article #409Re: Runtime.exec()
From: geoff_robinson
Date: Tue, 02 Nov 1999 00:00
Date: Tue, 02 Nov 1999 00:00
51 lines
1888 bytes
1888 bytes
Try breaking this apart so you can do a little debugging.
Process p = r.exec(command);
p.waitFor();
see if it works, then do the Input Stream stuff.
Geoff
In article <7vmjmm$s23$1@n.ruf.uni-freiburg.de>,
"Christoph Sperle" <sperle@wi.ba-loerrach.de> wrote:
> Hi,
>
> I have a Problem with the exec-Method of the Runtime-Object. On the
> DOS-Commandline this statement works propperly:
>
> command.com /c copy C:\print.ps lpt1
>
> but with the exec-Method it doesen't. Here is my Programm:
>
> import java.io.*;
>
> public class doscommand {
>
> public static void main (String[]args){
>
> int i;
> InputStream is;
>
> try{
> is = Runtime.getRuntime().exec("command.com /c copy
C:\\print.ps
> lpt1").getInputStream();
> while((i = is.read()) != -1) System.out.print((char)i);
> }
> catch(java.io.IOException e) {
> System.err.println(e.getMessage());
> System.exit(1);
> }
> }
>
> Why is this? Can anyone help me?
>
> Thank you, christoph.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID:
<7vn3ej$4ku$1@nnrp1.deja.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7vmjmm$s23$1@n.ruf.uni-freiburg.de>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10a146,4d3120dc2eea2114 X-Google-Attributes: gid10a146,public X-Google-Thread: f74b3,4d3120dc2eea2114 X-Google-Attributes: gidf74b3,public From: geoff_robinson@my-deja.com Subject: Re: Runtime.exec() Date: 1999/11/02 Message-ID: <7vn3ej$4ku$1@nnrp1.deja.com> X-Deja-AN: 543530678 References: <7vmjmm$s23$1@n.ruf.uni-freiburg.de> X-Http-Proxy: 1.0 x36.deja.com:80 (Squid/1.1.22) for client 192.91.146.35 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue Nov 02 16:28:08 1999 GMT X-MyDeja-Info: XMYDJUIDgeoff_robinson Newsgroups: comp.lang.java.programmer,borland.public.jbuilder.java.language X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I)