title: executing the customs command on linux with process builder in java
body: <p>I've been struggling for a while now with this problem and i can't seem to fix it. i have tried  <code>ProcessBuilder</code> for  executing the custom command on linux terminal but its not working</p>
  
  <p>Actually i have two <code>.sh</code> file <code>setProto.sh and setTls.sh</code> file which is used to set the environment.So for executing the command i need to run these two  file first for each instance of linux terminal.Only then we can be able to run the custom command <code>anloss</code> on the same instance of linux terminal in which .sh file supposed to run.For some reason i'm not able to make it work what is the mistake in my code ? Here's the code. </p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.File;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.lang.ProcessBuilder.Redirect;
  
  public class EngineTest {
  
      public static void main(String[] args) {
          try {
              ProcessBuilder builder = new ProcessBuilder(
                      "/. setProto.sh",
                      "/. setTls.sh",
                      "/anloss -i ${TOOL_INPUT}/census_10000_col5.csv  -d ${TOOL_DEF}/attr_all_def.txt -q k=14,dage=2 -g ${TOOL_RES}/census_100_col8_gen.csv");
              builder.directory(new File(System.getenv("HOME") + "/PVproto/Base"));
              File log = new File("log");
              builder.redirectErrorStream(true);
              builder.redirectOutput(Redirect.appendTo(log));
              Process process = builder.start();
  
              BufferedReader bufferedReader = new BufferedReader(
                      new InputStreamReader(process.getInputStream()));
              String line = "";
              String output = "";
              while ((line = bufferedReader.readLine()) != null) {
                  output += line + "\n";
              }
              System.out.println(output);
              int exitValue = process.waitFor();
              System.out.println("\n\nExit Value is " + exitValue);
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  }
  </code></pre>