Java- To run any exe application using java code

// To open any application

//using Runtime class

import java.io.*;
class demo
{
demo(){
try{

System.out.println("code by mobEDU");

Runtime r= Runtime.getRuntime();
System.out.println("application will be open");

r.exec("notepad.exe");
}
catch(Exception e){}
}
}

class run
{
public static void main(String args[])
{
demo d=new demo();
}
}


// using process class

import java.io.IOException;

public class ProcessExec{
 public static void main(String[] args){
 try
 {
 Process process = Runtime.getRuntime().exec("notepad.exe");
 }catch (IOException e)
 {
e.printStackTrace();
 }
 }

}

Reactions: