Thursday, April 16, 2009

Invoking a .exe from Java code

Invoking a .exe file from Java

pass the .exe file path as a command line argument

import java.io.*;
public class InvokeExe
{
public static void main(String[] args) throws IOException
{
if (args.length <= 0)
{
System.err.println("Need command to run");
System.exit(-1);
}
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(args);
System.exit(0);
}

}

No comments:

Post a Comment