🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #391

Re: Problem with Runtime.getRuntime().exec

#391
From: 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
Technical Details
Message-ID: <xn0e2ml291lyeyt000-kdean@www.teamb.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news.alt.net!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4293126c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,cf4ff3ee2b62af50
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com>
Subject: Re: Problem with Runtime.getRuntime().exec
Newsgroups: borland.public.jbuilder.java.language
References:  <4293126c@newsgroups.borland.com>
Organization: Dolphin Data Development Ltd.
User-Agent: XanaNews/1.17.4.1
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr
 p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Message-ID: <xn0e2ml291lyeyt000-kdean@www.teamb.com>
X-Ref: newsgroups.borland.com ~XNS:000001DF
NNTP-Posting-Host: 130.15.200.146
Date: 24 May 2005 06:49:04 -0700
X-Trace: newsgroups.borland.com 1116942544 130.15.200.146 (24 May 2005 06:49:04 -0700)
Lines: 40
X-Authenticated-User: kdean
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news.alt.net!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail