The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 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:

exec call

Posted by Matt Gerrans on October 22, 2001 at 5:47 PM

No, front slash '/' is not special, backslash '\' is (it is an escape character for strings). If you are using the path "c:/pathname/java.exe", you don't need to (and shouldn't) double them. If you are using the path "c:\\pathname\\java.exe"
(on Windows, where the directory separator is '\'), then you do (and must) double them.

As for the original question, what do you mean by "doesn't work?"
If the target program is a console app, then it is probably working just as expected; the window appears, does its thing and then goes away. This is how console apps work when launched directly from other apps. If you run it on a command line, you see the output, because your command shell is still there, even though the console app you called "went away". If it is a GUI app you are running and nothing is appearing, that's another story (but you didn't say anything about this).

If it is a console app, you just need add a "hit any key" (and wait for input) to the end of the program. If the program is beyond your control, you can wrap it in a batch file with the call to it followed by pause and have your program call the batch (or even dynamically create the batch in %temp%, as needed, then call it). Or, finally, you can find and modify the pif file for java.exe and change it to not "close window on exit." (I'll rent you my copy of Windows Undocumented File Formats, if you need to do this programmatically).

- mfg

> i think, it doesn't works beause "/" is a special sign. to make the compiler accepting it, you have to put "//".Like
> try{
> Runtime.getRuntime().exec(
> "c://pathname//java.exe -jar MyPgm.jar");
> }
> catch(IOException ioe){ioe.printStackTrace();}





Replies:

Sponsored Links



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