title: rJava fails to install (MacOS, Red Hat)
body: <p>I am experiencing the same rJava problem that many other people seem to of had at one point or another. The error occurs when <code>R CMD INSTALL</code> tests whether JNI programs can be compiled. </p>
  
  <p>The output recommends running <code>R CMD javareconf -ed</code> or <code>sudo R CMD javareconf</code> The output of the latter is : </p>
  
  <pre><code>computer: home$ sudo R CMD javareconf
  Java interpreter : /usr/bin/java
  Java version     : 1.6.0_31
  Java home path   : /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
  Java compiler    : /usr/bin/javac
  Java headers gen.: /usr/bin/javah
  Java archive tool: /usr/bin/jar
  Java library path: 
  JNI linker flags : -framework JavaVM
  JNI cpp flags    : -I$(JAVA_HOME)/include
  
  Updating Java configuration in /Library/Frameworks/R.framework/Resources
  Done.
  </code></pre>
  
  <p>And when trying to install rJava afterwards,</p>
  
  <pre><code>computer: home$ R CMD INSTALL ~/Downloads/rJava_0.9-4.tar.gz 
  * installing to library ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library’
  * installing *source* package ‘rJava’ ...
  checking for gcc... gcc -arch x86_64 -std=gnu99
  checking for C compiler default output file name... a.out
  /* Passes all checks */
  configure: checking whether gcc -arch x86_64 -std=gnu99 supports static inline...yes
  checking whether setjmp.h is POSIX.1 compatible... yes
  checking whether sigsetjmp is declared... yes
  checking whether siglongjmp is declared... yes
  checking Java support in R... present:
  interpreter : '/usr/bin/java'
  archiver    : '/usr/bin/jar'
  compiler    : '/usr/bin/javac'
  header prep.: '/usr/bin/javah'
  cpp flags   : '-I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include'
  java libs   : '-framework JavaVM'
  checking whether JNI programs can be compiled... configure: error: Cannot compile a simple JNI program. See config.log for details.
  
  Make sure you have Java Development Kit installed and correctly registered in R.
  If in doubt, re-run "R CMD javareconf" as root.
  
  ERROR: configuration failed for package ‘rJava’
  * removing ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava’
  * restoring previous ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava’
  </code></pre>
  
  <p>An alternative attempt where <code>/usr/bin/javac</code> is replaced by <code>/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home</code>fails just the same. </p>
  
  <p>I am running Mac OS 10.7.3 and</p>
  
  <pre><code>computer: home$ java -version
  java version "1.6.0_31"
  Java(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3646)
  Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01-415, mixed mode)
  </code></pre>
  
  <p>The following is in my <code>.bash_profile</code></p>
  
  <pre><code>export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
  </code></pre>
  
  <p>Additionally, I have the same problem on Red-Hat. I hope any fix provided will work there too, but if it won't and why it won't is know, please explain.  </p>
  
  <p>I've been using this site's incredible knowledge base for a couple of years now, but this is my first post. Mucho thanks in advance. </p>
  
  <p>Some (not all) of the resources I have already browsed through are</p>
  
  <ul>
  <li><a href="https://stat.ethz.ch/pipermail/r-devel/2008-November/051224.html" rel="nofollow noreferrer">https://stat.ethz.ch/pipermail/r-devel/2008-November/051224.html</a>  </li>
  <li><a href="https://stat.ethz.ch/pipermail/r-help/2008-October/177688.html" rel="nofollow noreferrer">https://stat.ethz.ch/pipermail/r-help/2008-October/177688.html</a></li>
  <li><a href="https://stackoverflow.com/questions/3311940/r-rjava-package-install-failing">R: rJava package install failing</a>  </li>
  </ul>
  
  <p>Please note that the <code>apt-get</code> solution in the last link is of no use to me (I think) unless there is an equiv solution for <code>port</code> and/or <code>yum</code>.</p>