public Process exec(String[] cmdarray) throws IOException Executes the specified command and arguments in a separate process. The command specified by the tokens in cmdarray is executed as a command in a separate process. This has exactly the same effect as exec(cmdarray, null). If there is a security manager, its checkExec method is called with the first component of the array cmdarray as its argument. This may result in a security exception.Parameters: cmdarray - array containing the command to call and its arguments. 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 See Also: exec(java.lang.String[], java.lang.String[]), SecurityManager.checkExec(java.lang.String)
public Process exec(String[] cmdarray)
throws IOException
Executes the specified command and arguments in a separate process.
The command specified by the tokens in cmdarray is executed as a command in a separate process. This has exactly the same effect as exec(cmdarray, null). If there is a security manager, its checkExec method is called with the first component of the array cmdarray as its argument. This may result in a security exception.Parameters:
cmdarray - array containing the command to call and its arguments.
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
See Also:
exec(java.lang.String[], java.lang.String[]), SecurityManager.checkExec(java.lang.String)
我的代码
Runtime.getRuntime().exec(getClass().getResource("help/index.htm").toString());
可是不行,应给怎么样写才对呢?
怎么回事啊?
但是Runtime.getRuntime().exec("cmd");却没问题
即使Runtime.getRuntime().exec("iexplore");也汇报错。
请问cmd和iexplore有什么区别?
即使直接运行Runtime.getRuntime().exec("iexplore");
也出错。
但是Runtime.getRuntime().exec("cmd"); 却是对的。
怎么回事啊?
其实正常嘛,你试试在dos窗口直接执行iexplore?一样报错呀!!!所以你要这样了:Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE e:\\ttt.txt");