Control Applications Using Java Java by Rajesh Kumar Sahanee - August 19, 2015August 19, 20150 Post Views: 6,968 Today I am going to create a java program by which you can control other application/software. In this program “ProcessBuilder” Class is used. ProcessBuilder class is predefined class which provides feature to start a process. There is start method in this class which is responsible for starting the process and it returns “Process” object. Using Process object you can stop/destroy that process also which was started earlier using ProcessBuilder object. I am not using Process object in this program but you can use it according to your program/application logic. So here is the code, just copy or type the code into notepad or your favorite text editor and save it as ControlApp.java. Then compile it and run it and follow the instruction. ControlApp.java Java import java.util.Scanner; class ControlApp{ public static void main(String args[]) throws Exception{ Scanner scn = new Scanner(System.in); int option; do{ System.out.println("1. Open Notepad\n2. Open Paint\n3. Open Internet Explorer\n4. Open Window Media Player"); System.out.print("Choose Option: "); option = scn.nextInt(); switch(option){ case 1: new ProcessBuilder("notepad.exe").start(); System.out.println("Notepad Started"); break; case 2: new ProcessBuilder("mspaint.exe").start(); System.out.println("Paint Started"); break; case 3: new ProcessBuilder("C:/Program Files/Internet Explorer/iexplore.exe").start(); //provide here path of internet explorer exe System.out.println("Internet Explorer Started"); break; case 4: new ProcessBuilder("C:/Program Files/Windows Media Player/wmplayer.exe").start(); //provide here path of window media player exe System.out.println("Window Media Player Started"); break; } }while(option != 0); System.out.println("Thank You! for using me"); } } 123456789101112131415161718192021222324252627 import java.util.Scanner;class ControlApp{ public static void main(String args[]) throws Exception{ Scanner scn = new Scanner(System.in); int option; do{ System.out.println("1. Open Notepad\n2. Open Paint\n3. Open Internet Explorer\n4. Open Window Media Player"); System.out.print("Choose Option: "); option = scn.nextInt(); switch(option){ case 1: new ProcessBuilder("notepad.exe").start(); System.out.println("Notepad Started"); break; case 2: new ProcessBuilder("mspaint.exe").start(); System.out.println("Paint Started"); break; case 3: new ProcessBuilder("C:/Program Files/Internet Explorer/iexplore.exe").start(); //provide here path of internet explorer exe System.out.println("Internet Explorer Started"); break; case 4: new ProcessBuilder("C:/Program Files/Windows Media Player/wmplayer.exe").start(); //provide here path of window media player exe System.out.println("Window Media Player Started"); break; } }while(option != 0); System.out.println("Thank You! for using me"); }} Output 1. Open Notepad 2. Open Paint 3. Open Internet Explorer 4. Open Window Media Player 0. Exit Choose Option (0 – 4): Thank You Please Share if you like it