How to open exe in java
In java, RunTime.getRuntime().exec() implements the call Server command scripts are required to perform functions.
Usage: (Recommended tutorial: java tutorial)
public Process exec(String command)-----在单独的进程中执行指定的字符串命令。 public Process exec(String [] cmdArray)---在单独的进程中执行指定命令和变量 public Process exec(String command, String [] envp)----在指定环境的独立进程中执行指定命令和变量 public Process exec(String [] cmdArray, String [] envp)----在指定环境的独立进程中执行指定的命令和变量 public Process exec(String command,String[] envp,File dir)----在有指定环境和工作目录的独立进程中执行指定的字符串命令 public Process exec(String[] cmdarray,String[] envp,File dir)----在指定环境和工作目录的独立进程中执行指定的命令和变量
1. First, call the application that comes with the windows system
Then put it in main as a test, run the java file, that is, open Notepad The application
2. The second method directly uses the local full path to run. Take the application as shown in the figure as an example. This is its startup program. Directory path
and then use the line of code shown in the figure to execute. In fact, the difference from the first method is whether the full path of the file that needs to be started is required.
3. The last method is to use the String[] array to pass parameters to start the application
In this way, the specified file will be opened with notepad.
The above is the detailed content of How to open exe file in java. For more information, please follow other related articles on the PHP Chinese website!