The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Runtime.exec()

Posted by Matt Gerrans on October 25, 2001 at 10:38 PM

> > Actually Chin, it is not that simple using Runtime.exec() does not behave like running the commands from command prompt. There is a fair bit of mystery behind Runtime.exec().

What do you mean? For the most part, it is like running the exec() or system() of other APIs, isn't it? Seems to work okay. Using the system(), WinExec(), CreateProcess(), ShellExecute(), exec(), pexec() in C/C++, Delphi, Python, etc. all have the usual caveats, especially when launching console or 16-bit (on Win32 platform) apps whose "window" you wish to control in some way.

I was going to mention that on the windows platform, you should use the environment variable %comspec%, not cmd.exe or command.com, since it is not always guaranteed that these are in the path and there are many variations with Win95/8/Me/NT/XP, etc. However, I see that System.getenv(), is not only deprecated, but also not available, so I don't know how you'd get that variable (it is not among the "replacement" System.getProperty()'s properties).

- mfg



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us