use java to execute the cmd and compile to jar file

 try {
            String cmd = "cmd.exe /c http://www.google.com/";
           Process process = Runtime.getRuntime().exec("cmd.exe /c start http://www.google.com/");

           //use ping
           Process ee = Runtime.getRuntime().exec(

             "cmd.exe  /c start ping www.google.com");

           // build the ".java" to ".class"
           Process jac = Runtime.getRuntime().exec(
             "cmd.exe  /c start javac C://testapp//Main.java");
          // compile to ".jar" file
           Process jar = Runtime.getRuntime().exec(
             "cmd.exe  /c start jar cvf D://jello.jar C://testapp//Main.class");// to different directry.


          } catch (Exception e) {
           e.printStackTrace();
          }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章