Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running an exe from Java

Status
Not open for further replies.

whodaman

Programmer
May 23, 2001
60
CA
I'm trying to make a local java appication that would like to run an exe file with a parameter (say a text file). I've looked into several books and it said nothing about it. Thank you in advance.
 
In the JDK look at java.lang.Runtime.exec()

Also search in for an article on how to use Runtime.exec() correctly. There are a few issues that you need to be concerned with.

Also, does it have to be your own Java program. I recommend you take a look at Ant project at jakarta.apache.org. The use of Ant is quite easy. There is a supported task called 'exec'. It may be easier for you to create a build.xml file then to interface with Ant from your Java program????

Pfist
 
Hi whodaman,
It is possible to invoke an application with parameters.
For eg.,
Runtime r = Runtime.getRuntime();
r.exec("notepad");
would open an untitled notepad, while,
r.exec("notepad c:\\logfile.txt");
would open up the logfile.txt file.
So the same, should be applicable to other applications too.
Hope this helps.

Regards,
Rajarajan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top