1

I'm trying to run the xlsx package on R but returns this error:

> library(xlsx)
JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
 call: .jinit()
 error: JNI_GetCreatedJavaVMs returned -1

Error: package or namespace load failed for ‘xlsx’

I found this link here on Stackoverflow Cannot load R xlsx package on Mac OS 10.11 but it isn't working for me.

The solution was to run sudo R CMD javareconf on Mac Terminal and after install.packages("rJava",type='source') on R. But when I run sudo R CMD javareconf my Mac gives this error: sudo: R: command not found.

Does anyone know how can I fix this issue?


OS Version:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.5
BuildVersion:   15F34

Java Version:

$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

R Version:

> version
           _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          2.3                         
year           2015                        
month          12                          
day            10                          
svn rev        69752                       
language       R                           
version.string R version 3.2.3 (2015-12-10)
nickname       Wooden Christmas-Tree
Community
  • 1
  • 1
Rods2292
  • 665
  • 2
  • 10
  • 28
  • 2
    You might take a look at the `openxlsx` package which doesn't require Java. – lmo Jun 19 '16 at 20:20
  • Your R and Java are out of date, which may or may not be causing the issues. It might be a PATH issue, but I doubt it. – alistaire Jun 19 '16 at 20:28
  • remove the new java, install the [older java](https://support.apple.com/kb/DL1572?locale=en_US) and redo the `javareconf`. Various java-based R pkgs - including & especially those based on `rJava` - seem to not like modern java installs on OS X. – hrbrmstr Jun 19 '16 at 20:28
  • @hrbrmstr I ran the code shown here https://www.java.com/en/download/help/mac_uninstall_java.xml to uninstall Java but nothing happened on Terminal. I downloaded and tried to install an old version of Java from Apple website but it reported an error message saying that I couldn't do that because I already have a new version of Java – Rods2292 Jun 19 '16 at 20:42

1 Answers1

0

The error message from your Terminal session actually suggest that your bash PATH does not have the directory for the R executable (or a symlink to it.) But I'm also wondering if augmenting your PATH value will be successful.

The El Capitan version of OSX changed the security policies and move the location for user installed software. I got success after failing with javareconf by issuing this command at a Terminal prompt and then giving my password:

sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • I am facing the same issue after upgrading to Sierra http://stackoverflow.com/questions/40511438/rjava-load-error-after-upgrade-to-sierra?noredirect=1#comment68265401_40511438 any suggestions? – Dambo Nov 09 '16 at 20:52
  • Your error message suggests you don't even have a Java VM but if you know that you do, then you should edit your question to include all the relevant information. – IRTFM Nov 09 '16 at 22:17