1 2 Previous Next 18 Replies Latest reply: Mar 6, 2013 3:25 PM by EJP Go to original post RSS
      • 15. Re: Running windows command through java code
        EJP
        There's not much effort in evidence there. You haven't got rid of 'cmd /c', and you've made zero effort about setting PATH in the environment, which was the only reason for using the ProcessBuilder in the first place. If you really think computer programming is entirely a matter of cut and paste, you have a rude shock waiting for you somewhere down the line. I wouldn't put up with this sort of thing from anyone working for me.
        • 16. Re: Running windows command through java code
          mjmjava
          But Sir ,
          i have set it path in my environment , it is there from long time as result following code is working

          String directory = System.getenv("java_home")+"\\bin";
                    String[] command = {"cmd.exe","/c","jar.exe"};
                    
                    ProcessBuilder processBuilder = new ProcessBuilder(command);
                    processBuilder.directory(new File(directory));
                    Process pro = processBuilder.start();
                    BufferedReader buf = new BufferedReader(new InputStreamReader(pro.getErrorStream()));
                    String line ;
                    while ((line = buf.readLine()) != null) {
          System.out.println(line);
          but still i am unaware about , getting rid of 'cmd/c' , and i have made effort but i am new to system and path related structure of java so i am unable to pick these things fast , so sorry for that

          Regards
          • 17. Re: Running windows command through java code
            Tolls
            http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html

            That's the API for ProcessBuilder, whch includes an example of setting one up with it's own environment...which is what EJP is talking about, and you would have found with even a cursory look at the API.

            Don't just grab a class and hope to be able to use it. Read the documentation.
            • 18. Re: Running windows command through java code
              EJP
              i have set it path in my environment
              You didn't say so, even after I reminded you of the issue. And you had no other reason to switch to ProcessBuilder. So why did you do that again?
              but still i am unaware about , getting rid of 'cmd/c'
              You cannot possibly be 'unaware' of it. I mentioned it above, in answer to another of your questions. Read the thread.

              I conclude that you aren't reading the answers to your own questions.

              You're wasting time.
              1 2 Previous Next