-2

Possible Duplicate:
Running a .exe file using Java

How can i run a .exe file from my java Program ?
Is it possible ?

Community
  • 1
  • 1
Abhij
  • 1,222
  • 4
  • 19
  • 37
  • 1
    Welcome to Stack Overflow. Please use the search (or google) before asking new questions; many have already been asked and answered. – Brian Roach Feb 07 '12 at 07:17
  • Take a look at the `Runtime.exec`, as shown [here](http://www.ozzu.com/programming-forum/how-execute-exe-file-useing-java-program-t21081.html). – npinti Feb 07 '12 at 07:17

4 Answers4

1

U can use the following code.........

Runtime rt = Rintime.getRuntime() ;     
Process p => rt.exec("Program.exe") ;     
NIVESH SENGAR
  • 1,285
  • 5
  • 19
  • 43
0

Use this code

try
{
    Runtime r = Runtime.getRuntime();
    Process p2 = r.exec("a.exe"); //absolute or relative path
}
catch(IOExeption ex)
{
    System.out.println(ex.getMessage());
}
Sunil Kumar B M
  • 2,735
  • 1
  • 24
  • 31
0

If you have the privileges, you can run OS's commands with this:

String cmd = "c:/full/path/to/myCommand.exe";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
Andrea Colleoni
  • 5,919
  • 3
  • 30
  • 49
0
import java.io.IOException;

public class ExeRunner 
{
    public static void main(String args[]) throws IOException 
    {
        ProcessBuilder proc = new ProcessBuilder("<your_exe>", "exe_args");
        proc.start();
    }
}

Refer: ProcessBuilder vs Runtime.exec()

Community
  • 1
  • 1
Azodious
  • 13,752
  • 1
  • 36
  • 71