🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
2 messages
2 total messages Started by tolis Tue, 24 May 2005 11:41
Problem with Runtime.getRuntime().exec
#390
Author: tolis
Date: Tue, 24 May 2005 11:41
29 lines
1476 bytes
Hi ,
i'm using jBuilderX and windows 2000 server . My problem is that i can't
find why
in my code it doesn't work this:

.................
import java.lang.*;
.................

String command = new String("c:\\testd\\testf.bat");      // testf.bat -
batch file
Runtime.getRuntime().exec(command);                         // it doesn't
have any effect
..................................



Thanks in advance,
Hatziyannis Apostolis








-- 
______________________________
Re: Problem with Runtime.getRuntime().exec
#391
Author: Kevin Dean [TeamB]
Date: Tue, 24 May 2005 13:49
40 lines
2200 bytes
tolis wrote:

> i'm using jBuilderX and windows 2000 server . My problem is that i
> can't find why
> in my code it doesn't work this:
> 
> .................
> import java.lang.*;
> .................
> 
> String command = new String("c:\\testd\\testf.bat");      //
> testf.bat - batch file
> Runtime.getRuntime().exec(command);                         // it
> doesn't have any effect

Try this:

String command = "cmd.exe /c c:\\testd\\testf.bat";

1) A string is automatically allocated when you put stuff in
double-quotes.
2) Batch files are not themselves executable; the command processor
(cmd.exe) is required to run them with the "/c" switch.

For a better understanding of Runtime.exec():

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

-- 
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
http://www.datadevelopment.com/papers/index.html

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads