tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > Runtime > Invoke External Applications

Invoke External Applications 

This tutorial shows how to list all system properties in one shot and execute external programs through java. We can use Runtime to execute any windows or Linux binary file. If your executable is in system PATH you can directly specify the executable name otherwise you need to specify the executable with full path. Still in doubt check the PATH environment variable. As notepad.exe is available in folder C:\WINDOWS\system32 which is already appended to system PATH we don't need to specify the full path.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.runtime;


public class RuntimeTest {

   @param args
  public static void main(String[] args) {

    //List system properties
    //Executable in system PATH
    try {
      Runtime.getRuntime().exec("notepad.exe C:\\Realtek.log");
    catch (IOException e) {    
    //Executable not in system PATH
    try {
    catch (IOException e) {    

It gives the following output, SE Runtime Environment
sun.boot.library.path=C:\Program Files\Java\jre1.6.0_02\bin
java.vm.vendor=Sun Microsystems Inc.
Along with the console output it opens the notepad and sample window as shown below,



bl  br