Runtime class in java

后端 未结 6 975
野性不改
野性不改 2020-12-18 12:03

How to execute a java program with the help of Runtime.getRuntime().exec(). For example we shall have the java file path as c:/java/abc.java. Please help me with the code.

6条回答
  •  无人及你
    2020-12-18 12:35

    You should use ProcessBuilder instead of Runtime. Basic usage is like:

    Process process = new ProcessBuilder(command).start();
    

    You will find more code under the link above. Also see this question.

提交回复
热议问题