How can I run an .exe file in java?
thank you!
Best Regards,
Kevin Shen
Printable View
How can I run an .exe file in java?
thank you!
Best Regards,
Kevin Shen
Hi !
You should you the Runtime and Process classes to Perform this. Below is a small Program, that will Illustrate this for you.
/** RunFromJava.java : Demonstrates, How to Execute a Program from within Java */
import java.lang.* ;
public class RunFromJava
{
public static void main(String[] args)
{
Runtime r = Runtime.getRuntime();
Process p = null;
try
{
p=r.exec("Freecell"); // Starts the "Free Cell" Game
p.waitFor();
}
catch (Exception e)
{
System.out.println("Error executing C" + e.toString());
}
}
}
Hope this helps.
Enjoy Java.
-Vipul Pathak.
Pathak Developers Pvt. Ltd.
Indore, (MP) INDIA.
PS: If this helps you then Rate it, so let me know How much is this helpful to you.