The preceding Java code helps to open the application.
- import java.io.*;
- class Demo {
- public static void main(String[] args) {
- Runtime rs = Runtime.getRuntime();
- try {
- BufferedReader br = new BufferedReader(new InputStreamReader(System. in ));
- System.out.println("1-Want to open notepad");
- System.out.println("2-Want to open calculator");
- System.out.println("2-Want to open control panel");
- System.out.println();
- System.out.print("Select any option: ");
- int select = Integer.parseInt(br.readLine());
- switch (select) {
- case 1:
- rs.exec("notepad");
- break;
- case 2:
- rs.exec("calc");
- break;
- case 3:
- rs.exec("control panel");
- default:
- System.out.println("");
- }
- } catch (IOException e) {
- System.out.println(e);
- }
- }
- }
Thank you, keep learning and sharing.