How to Invoke Other Applications in Java


In this example we will show how to invoke other applications in Java.

Source Code

package com.beginner.examples;

import java.io.IOException;

public class InvokeExample {

    public static void main(String[] args){
    	 // By using ProcessBuilder class, you can invoke any application in Java.
    	 ProcessBuilder p = new ProcessBuilder("java", "Example");
         try 
         {
             p.start();
             System.out.println("The application has been started.");
         } 
         catch (IOException e) 
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
    }
}

Output:

The application has been started.

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments