title: Java ProcessBuilder not able to run Python script in Java
body: <p><code>null</code> from <code>bfr.readLine()</code></p>
  <p>However, there is no problem if I run the python file directly on terminal by firing:</p>
  <blockquote>
  <p>python C:/Machine_Learning/Text_Analysis/Ontology_based.py</p>
  </blockquote>
  <p>The last line in my Python script is <code>&gt;&gt; print(data)</code></p>
  <p>The result of the following code is:</p>
  <p>Running Python starts:</p>
  <blockquote>
  <p>First Line: null</p>
  <p>Picked up _JAVA_OPTIONS: -Xmx512M</p>
  </blockquote>
  <hr />
  <pre><code>package text_clustering;
  
  import java.io.*;
  
  public class Similarity {
  
      /**
       * 
       * @param args
       * 
       */
      public static void main(String[] args){
          try{
              String pythonPath = &quot;C:/Machine_Learning/Text_Analysis/Ontology_based.py&quot;;
              //String pythonExe = &quot;C:/Users/AppData/Local/Continuum/Anaconda/python.exe&quot;;
              ProcessBuilder pb = new ProcessBuilder(&quot;python&quot;, pythonPath);
              Process p = pb.start();
              
              BufferedReader bfr = new BufferedReader(new InputStreamReader(p.getInputStream()));
              String line = &quot;&quot;;
              System.out.println(&quot;Running Python starts: &quot; + line);
              line = bfr.readLine();
              System.out.println(&quot;First Line: &quot; + line);
              while ((line = bfr.readLine()) != null){
                  System.out.println(&quot;Python Output: &quot; + line);
                  
                  
              }
  
          }catch(Exception e){System.out.println(e);}
      }
  
  }
  </code></pre>