java.lang.Process pro=java.lang.Runtime.exec(String command);

解决方案 »

  1.   

    是用java开发的exe程序吗?如果是,可以在java中直接调用,就像使用其他类一样。如果不是,就需要用jni来调用了。
      

  2.   

    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 .
      

  3.   

    我执行了java.lang.Process pro=java.lang.Runtime.exec(String command);系统提示:java.io.IOException: CreateProcess: PrjControlCenter.exe error=2 请问该如何解决?
      

  4.   

    String command = "PrjControlCenter.exe";
    Runtime rt = Runtime.getRuntime(); 
    try{
    Process pro=rt.exec(command);
    }
    catch(IOException e){
    out.println(e);
    }
      

  5.   

    他说找不到文件,试试下面的。
    你用什么编译器? 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);
      

  6.   

    应该是:
    java.lang.Process pro=java.lang.Runtime.getRuntime().exec(String command);

    exec不是类方法,你要先得到它的实例
      

  7.   

    Sorry 没用过。 可能是你的路径不对,我再Forte中,调试是他指向了Forte的目录,可能有一项设置路径的,我也是刚用。
      

  8.   

    error =2表示你的路径可能有问题,它找不到
      

  9.   

    qiaojiannan(JNQ),
    我执行了你的方法后,现在没有系统调用了这个exe的现象,请问是怎么回事?
      

  10.   

    路径的问题啦!你可以把你的程序路径放到系统的PATH中或者COMMAND中写上绝对路径!
      

  11.   

    用的是Windows 2000 Advance serve
      

  12.   

    qiaojiannan(JNQ) :
    本来这个exe各行后,将出现一个vb所做的一个录入窗口,但现在调用之后这个窗口并没有显示出来,但系统也没有提示任何错误信息.谢谢!
      

  13.   

    "没有系统调用了这个exe的现象"什么意思? Notepad 没启动?
    ================================================================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    [自解压]
      

  14.   

    Runtime rt = Runtime.getRuntime();
          Process p1;
          p1 = rt.exec(@execFile);
      

  15.   

    补充:@execFile是文件名,比如说:C:\setup.exe
      

  16.   

    你直接在Run里面敲要运行的命令行。
    ================================================================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    [自解压]