1 2 Previous Next 18 Replies Latest reply: Mar 6, 2013 3:25 PM by EJP RSS

    Running windows command through java code

    mjmjava
      Hello
      i want to execute jar.exe through java code , i have written following piece of code , but it isn't working

      ProcessBuilder processBuilder = new ProcessBuilder(new String[]{"cmd.exe","/c","%java_home%\\bin\\jar.exe"});
                Process process = processBuilder.start();
                BufferedReader inputReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                String line = inputReader.readLine();
                while(line != null){
                     System.out.println(line);
                     line = inputReader.readLine();
                }

      does anybody knows why

      Regards

      Edited by: Mayur Mitkari on Mar 5, 2013 10:19 PM

      Edited by: Mayur Mitkari on Mar 5, 2013 10:20 PM

      Edited by: Mayur Mitkari on Mar 5, 2013 10:20 PM
        1 2 Previous Next