try { Runtime.getRuntime().exec("可执行文件的命令"); }catch(Exception e) { } 这里最好加上异常处理,更详细的内容如下 public Process exec(String command) throws IOExceptionExecutes the specified string command in a separate process. The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a StringTokenizer created by the call: new StringTokenizer(command) with no further modifications of the character categories. This method has exactly the same effect as exec(command, null). Parameters: command - a specified system command. Returns: a Process object for managing the subprocess. Throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. IOException - if an I/O error occurs NullPointerException - if command is null IllegalArgumentException - if command is empty See Also: exec(java.lang.String, java.lang.String[]), SecurityManager.checkExec(java.lang.String)
{
Runtime.getRuntime().exec("可执行文件的命令");
}catch(Exception e)
{
}
这里最好加上异常处理,更详细的内容如下
public Process exec(String command)
throws IOExceptionExecutes the specified string command in a separate process.
The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a StringTokenizer created by the call: new StringTokenizer(command)
with no further modifications of the character categories. This method has exactly the same effect as exec(command, null). Parameters:
command - a specified system command.
Returns:
a Process object for managing the subprocess.
Throws:
SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess.
IOException - if an I/O error occurs
NullPointerException - if command is null
IllegalArgumentException - if command is empty
See Also:
exec(java.lang.String, java.lang.String[]), SecurityManager.checkExec(java.lang.String)