Java Code: How to open an application using java program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
public class JavaRunApplication { public static void main(String[] args) { Runtime app = Runtime.getRuntime(); try { // open notepad app.exec("notepad"); // open calculator app.exec("calc"); } catch (Exception Ex) { System.out.println("Error: " + Ex.toString()); } } } |
This program will open (run) applications (Notepad, Calculator) using Java program. To open/run application we are using instance of Runtime.getRuntime() and method exec().