你的位置:首页 > 软件开发 > Java > Runtime.exec() sucks!!!!

Runtime.exec() sucks!!!!

发布时间:2016-03-31 23:33:49
自己项目中使用到了Runtime rt = Runtime.getRuntime();Process p = rt.exec("query session");p.waitFor();结果在不同的windows 操作系统中,程序的运行不一致,在windows ...

自己项目中使用到了

Runtime rt = Runtime.getRuntime();Process p = rt.exec("query session");
  • Make room for JavaSpaces, Part 6
  • Modifying archives, Part 2: The Archive class
  • Navigate yourself around pitfalls related to the Runtime.exec() method
    1. A single string that represents both the program to execute and any arguments to that program
    2. An array of strings that separate the program from its arguments
    3. An array of environment variables

    Pass in the environment variables in the form name=value. If you use the version of exec() with a single string for both the program and its arguments, note that the string is parsed using white space as the delimiter via the StringTokenizer class.

    Stumbling into an IllegalThreadStateException

    The first pitfall relating to Runtime.exec() is the IllegalThreadStateException. The prevalent first test of an API is to code its most obvious methods. For example, to execute a process that is external to the Java VM, we use the exec() method. To see the value that the external process returns, we use the exitValue()method on the Process class. In our first example, we will attempt to execute the Java compiler (javac.exe):


    原标题:Runtime.exec() sucks!!!!

    关键词:

    *特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

    可能感兴趣文章

    我的浏览记录