Execute a Java program from our Java program

后端 未结 14 1844
名媛妹妹
名媛妹妹 2020-12-01 17:24

I used

Runtime.getRuntime().exec(\"_____\")

but it throws a IOException as below:

java.io.IOException: Create         


        
14条回答
  •  隐瞒了意图╮
    2020-12-01 17:30

    Put ant lib in you classpath ( project lib ) and run this code :

    import org.apache.tools.ant.taskdefs.Execute;
    
    Execute exe = new Execute();
    exe.setCommandline(new String[]{"java", "-version"});
    exe.execute();
    

提交回复
热议问题