title: Using Java exec to Run a jar from JSP with JRI
body: <p>I got a task to run R script in java, so I used the JRI library for this case, and I need call it from jsp, so I write a page simply call by</p>
  
  <pre><code>Runtime.getRuntime().exec("java -Djava.library.path=/home/XXX/R/x86_64-pc-linux-gnu-library/2.15/rJava/jri/ -cp /home/XXX/R/x86_64-pc-linux-gnu-library/2.15/rJava/jri -jar /home/XXX/MyJar.jar")
  </code></pre>
  
  <p>This method -> re.waitForR() always return false</p>
  
  <pre><code>Rengine re = new Rengine(new String[] { "--vanilla" }, false, null);
  if (!re.waitForR()) {
      System.out.println("Cannot load R");
      return;
  }
  </code></pre>
  
  <p>But when I run with console</p>
  
  <pre><code>java -Djava.library.path=/home/XXX/R/x86_64-pc-linux-gnu-library/2.15/rJava/jri/ -cp /home/XXX/R/x86_64-pc-linux-gnu-library/2.15/rJava/jri -jar /home/XXX/MyJar.jar
  </code></pre>
  
  <p>It is good and no error happened! </p>
  
  <p>How can I do?</p>
  
  <p>PS. My Jsp runs on Jetty.</p>