Runtime.getRuntime().exec("可执行文件的命令");
解决方案 »
- java正则表达式怎么样应用大侠给个事例
- 请教:这是一种什么用法?
- java的简单问题
- 请各位高手指点JAVA中的对象序列化是一个怎样的技术?
- hashcode与内存地址是什么关系?为什么在Object类中要把toString中的hashCode换成16进制后再显示?
- Date与GregorianCalendar都能表示时间和日期,那么它们的区别到底在那呢?
- 颜色的怎么更新???
- 那里有class12.jar下载!谢谢!急呀!
- 谁能讲解下统计“a,b,c,a,a,b,上海,上海”的思路
- 为OCJP盖个楼!(Welcome everyone~)
- 下面的代码什么意思?
- 问个很简单的问题(答得好给50,友情参与也给)
{
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)