Money Mgt Calculator
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of JBoss AS 5 Development this week in the JBoss forum
or Spring Dynamic Modules in Action in the Spring forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Java in General
 
RSS feed
 
New topic
Author

Can we call an executable(.exe) from Java program

Swaroop Reddy
Ranch Hand

Joined: Feb 25, 2009
Messages: 32

Hello ,
I have an executable file written using Vc++ ,i want to call it in my java program in such a way it should get executed and should start working
Is it possible if so please suggest me relative links and process how to do

Mr.Reddy
Maneesh Godbole
Bartender

Joined: Jul 26, 2007
Messages: 3872

If you want to invoke some application, check out the Runtime and ProcessBuilder API.
Moving to a more appropriate forum

work is the scourge of the drinking class
kiran kumar kondru
Greenhorn

Joined: Feb 21, 2007
Messages: 3

Hi

I think the Runtime class encompasses the execution of native code. Runtime.getRuntime().exec("notepad.exe"); for example runs the notepad. Remember that either the exe is in the PATH or give complete path to it.

This exec() method returns a Process object through which you can have more control like killing the process itself.

The following is a sample program.


And Miles to go before I sleep<br />And Miles to go before I sleep
Rob Prime
Bartender

Joined: Oct 27, 2005
Messages: 8261

And please read the JavaWorld article "When Runtime.exec() won't". Once you start with external processes, this article is a must-read.

SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Campbell Ritchie
Bartender

Joined: Oct 13, 2005
Messages: 14501

The java.lang.ProcessBuilder class makes it easier, but it simplifies the problems discussed in the Daconta article Rob quoted. You still must read it.
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Java in General
 
RSS feed
 
New topic
IntelliJ open source