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

Model Context Protocol (MCP) — Complete Guide for Backend Engineers

  Model Context Protocol (MCP) — Complete Guide for Backend Engineers Build Tools, Resources, and AI-Driven Services Using LangChain Moder...

Featured Posts