aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How do I invoke an .exe application from my JAVA program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How do I invoke an .exe application from my JAVA program?" Watch "How do I invoke an .exe application from my JAVA program?" New topic
Author

How do I invoke an .exe application from my JAVA program?

Anshuman Johri
Greenhorn

Joined: Mar 13, 2005
Posts: 2
Dear Members,
I want to invoke an application from my JAVA program.
The application is an .exe file and i need to pass parameters to it.
The application supports command line invoking.
I want my JAVA program to do this.
Please tell me how it can be done.
It is urgent for my project.
Waiting for your answers,
Thanks
Anshuman
INDIA
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30923
    
158

Anshuman,
Welcome to JavaRanch!

Take a look at Runtime.exec(). This allows you to make operating system calls from your java app.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Anshuman Johri
Greenhorn

Joined: Mar 13, 2005
Posts: 2
Thanks a lot Jeanne.
I got the answer.
Take care.
Cheers!
Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
import java.io.*;

class cmdtest
{
public static void main(String args[]) throws Exception
{
BufferedReader bufRead = cmdtest.executeCommand();
String str;
while((str = bufRead.readLine()) != null)
{
System.out.println("" + str);
}

}

public static BufferedReader executeCommand( ) throws IOException
{
String str;
Runtime rt=Runtime.getRuntime();
BufferedReader bufInp=null;
try
{
Process p=rt.exec("help");
Process p=rt.exec("ls -l");
bufInp=new BufferedReader ( new InputStreamReader ( p.getInputStream() ) );
}
catch ( IOException ioExc )
{
ioExc.printStackTrace();
System.out.println("IO Exception: " + ioExc.getMessage() );
}
return bufInp;
}
}

Probably this will help.

Rashid
 
Consider Paul's rocket mass heater.
 
subject: How do I invoke an .exe application from my JAVA program?