title: Error installing rJava on mac OSX 10.12.4
body: <p>I'm trying to install the <a href="https://cran.r-project.org/web/packages/xlsx/index.html" rel="nofollow noreferrer">xlsx</a> package on my mac, but I keep getting the error </p>
  
  <blockquote>
    <p>JavaVM FATAL: Failed to load the jvm library</p>
  </blockquote>
  
  <p>So, I've tried to follow the advice found in <a href="https://stackoverflow.com/a/40142387/2146894">this answer</a>, but I get hung up on the last step - installing <a href="https://cran.r-project.org/web/packages/rJava/index.html" rel="nofollow noreferrer">rJava</a>.  The error message(s) I get are</p>
  
  <pre><code>&gt; install.packages("rJava",type='source')
  trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-8.tar.gz'
  Content type 'application/x-gzip' length 656615 bytes (641 KB)
  ==================================================
  downloaded 641 KB
  
  * installing *source* package ‘rJava’ ...
  ** package ‘rJava’ successfully unpacked and MD5 sums checked
  checking for gcc... /usr/local/opt/llvm/bin/clang -fopenmp
  checking whether the C compiler works... no
  configure: error: in `/private/var/folders/nz/5zx8zy7d1yg4fxhtttcl7s_c0000gn/T/RtmpB2wCzM/R.INSTALL139d1a450fb0/rJava':
  configure: error: C compiler cannot create executables
  See `config.log' for more details
  ERROR: configuration failed for package ‘rJava’
  * removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rJava’
  * restoring previous ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rJava’
  Warning in install.packages :
    installation of package ‘rJava’ had non-zero exit status
  
  The downloaded source packages are in
      ‘/private/var/folders/nz/5zx8zy7d1yg4fxhtttcl7s_c0000gn/T/RtmpD4AWyg/downloaded_packages’
  </code></pre>
  
  <p>Prior to this, when I run <code>sudo R CMD javareconf</code> I get</p>
  
  <pre><code>Java interpreter : /usr/bin/java
  Java version     : 1.8.0_25
  Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
  Java compiler    : /usr/bin/javac
  Java headers gen.: /usr/bin/javah
  Java archive tool: /usr/bin/jar
  Non-system Java on macOS
  
  trying to compile and link a JNI program 
  detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
  detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
  /usr/local/opt/llvm/bin/clang -fopenmp -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/../include/darwin -I/usr/local/opt/llvm/include    -fPIC  -Wall -mtune=core2 -g -O2  -c conftest.c -o conftest.o
  /usr/local/opt/llvm/bin/clang -fopenmp -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/opt/llvm/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
  
  
  JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
  Java library path: $(JAVA_HOME)/lib/server
  JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
  JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
  Updating Java configuration in /Library/Frameworks/R.framework/Resources
  Done.
  </code></pre>
  
  <p>Any tips for fixing this issue?</p>