The following program allows you to run / execute other application from Java using the Runtime.exec()
method.
package org.kodejava.lang;
import java.io.IOException;
public class RuntimeExec {
public static void main(String[] args) {
//String command = "/Applications/Safari.app/Contents/MacOS/Safari";
String command = "explorer.exe";
try {
Process process = Runtime.getRuntime().exec(new String[]{command});
} catch (IOException e) {
e.printStackTrace();
}
}
}
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024