File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Can we call an executable(.exe) from Java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can we call an executable(.exe) from Java program" Watch "Can we call an executable(.exe) from Java program" New topic
Author

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

Swaroop Reddy
Ranch Hand

Joined: Feb 25, 2009
Posts: 34
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
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

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


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
kiran kumar kondru
Greenhorn

Joined: Feb 21, 2007
Posts: 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 Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36501
    
  16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we call an executable(.exe) from Java program
 
Similar Threads
Call executable program
using dll in java
How to call an executable (.exe) from java
running an executable file on the server by client
How to run an executable placed on linux sever on a host with java program