Process getRuntime.exec(String command) public static Runtime getRuntime() Returns the runtime object associated with the current Java application. Most of the methods of class Runtime are instance methods and must be invoked with respect to the current runtime object. Returns: the Runtime object associated with the current Java application. public Process exec(String command) throws IOException Executes 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 摘自Jdk1.4 doc .
Returns the runtime object associated with the current Java application. Most of the methods of class Runtime are instance methods and must be invoked with respect to the current runtime object. Returns:
the Runtime object associated with the current Java application.
public Process exec(String command)
throws IOException
Executes 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
摘自Jdk1.4 doc .
Runtime rt = Runtime.getRuntime();
try{
Process pro=rt.exec(command);
}
catch(IOException e){
out.println(e);
}
你用什么编译器? File f=new File(".");
System.out.println( f.getAbsolutePath() );
// TODO: Add initialization code here
String command = "notepad.exe";
Runtime rt = Runtime.getRuntime();
try{
Process pro=rt.exec(command);
}
catch(IOException e){
System.out.println(e);
java.lang.Process pro=java.lang.Runtime.getRuntime().exec(String command);
吧
exec不是类方法,你要先得到它的实例
我执行了你的方法后,现在没有系统调用了这个exe的现象,请问是怎么回事?
本来这个exe各行后,将出现一个vb所做的一个录入窗口,但现在调用之后这个窗口并没有显示出来,但系统也没有提示任何错误信息.谢谢!
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]
Process p1;
p1 = rt.exec(@execFile);
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]