The method exec() present in java.lang.Runtime class is used for opening application that are installed in your system. See the below example.
public class ExecDemo {
public static void main(String args[]) {
try{
Runtime.getRuntime().exec("notepad.exe ExecDemo.java");
}
catch(Exception e) {
e.printStackTrace();
}
}
}
Here the "notepad.exe" refer the name of the exe name and "ExecDemo.java" refer the file name. The file present in some other directory then you need to give the full path of the file.
Comments