ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajkumar Seth <Seth.Rajku...@GNI.co.uk>
Subject RE: calling dos start
Date Tue, 22 May 2001 11:54:21 GMT
Runtime exec depends on the OS  to locate, load and start the required
program. 
If the program annot be found or the Os does nto have enough resources to
start 
the program, or the application is already open, or the program is open and
busy 
the OS may not be able to create a process hence the error thrown.

There are some common mistakes...


To get a full (long) listing of files in the current directory. But getting
a listing
in this way highlights a fundamental weakness of using Runtime.exec --
the programs you invoke aren't necessarily portable. That is,
Runtime.exec is portable, and exists across different Java
implementations, but the invoked programs are not. There's no program
named "ls" on Windows systems. Suppose that you're running Windows NT
and you decide to remedy this problem by saying: 

runCommand("dir"); <P>

Where "dir" is the equivalent command to "ls". This doesn't work,
because "dir" is not an executable program. Instead it is built into
the shell (command interpreter) CMD.EXE. So you need to say:
runCommand("cmd c dir") where "cmd /c command" says "invoke a shell and
execute the single specified command and then exit." Similarly, for a
UNIX shell like the Korn shell, you might say: runCommand("ksh -c
alias") where "alias" is a command built into the shell. The output in
this case is a list of all your shell aliases.

-----Original Message-----
From: Boris Garbuzov [mailto:boris.garbuzov@borealissoft.com]
Sent: 2001 May 18 06:38
To: ant-user@jakarta.apache.org
Subject: Re: calling dos start


I also have this problem. And I had it before ant sometimes in stand-alone
applications saying
Runtime.getRuntime().exec("mydoscommand");
Try it in this simple mode first. But I would be curious to hear from
specialists why java sometimes can not create runtime process. What it
depends
on?

---------------



Ivan Novick wrote:

> Hi all,
>
> I would like to write some code in an ant file to run the following
command
> on dos
>
> start java ${serverclass}
>
> This was my attempt:
>
> <target name="server">
>       <exec dir="${src}" executable="start">
>            <arg value="java ${serverclass}"/>
>       </exec>
> </target>
>
> The error message I get is:
>
> java.io.IOException: Create process: start "java HelloServer" error=2
>
> Does any one know how to write code to execute the command above?  Thank
you
> for any input or ideas.
> Ivan


************************************************************************
The contents of this message and any attachments are confidential and
are intended solely for the attention and use of the addressee only.
Information contained in this message may be subject to legal, 
professional or other privilege or may otherwise be protected by other
legal rules. This message should not be copied or forwarded to any other
person without the express permission of the sender. If you are not the
intended recipient you are not authorised to disclose, copy, distribute
or retain this message or any part of it.

If you have received this message in error, please notify the sender by
telephone (+44-20-7002-4000) and destroy the original message.

We reserve the right to monitor all e-mail messages passing through our
network.
************************************************************************

Mime
View raw message