How to run external application from java

Java Runtime that allows the application to interface with the environment in which the application is running. The getRunTime().exec() method allows to execute external application from java.

Example

package com.pretech;
import java.io.IOException;
public class JavaRunTimeExample {
	public static void main(String[] args) {
		try {
			Runtime.getRuntime().exec("notepad.exe c:/pretech.txt");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Output



image


No comments:

Post a Comment

12 classic String-based Java interview questions with simple explanations and code.

  1️⃣ Check if a String is a Palindrome Problem Given a string, check if it reads the same forward and backward. Example: "madam...

Featured Posts