Install RWeka on Mac

I was not able to install the R-package FSelector, because a dependency could not be installed properly.

It was RWeka, which exits with the following error:

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 'RWekajars', details:
call: .jinit()
error: JNI_GetCreatedJavaVMs returned -1

ERROR: lazy loading failed for package 'RWeka'

  • removing '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/RWeka'
    Warning in install.packages :
    installation of package 'RWeka' had non-zero exit status

But I found an easy solution: First install the newest Java version (It is important to use the same bit-version [e.g., 32 or 64-bit] like R). Then open a terminal and run:

sudo R CMD javareconf

Now open a R-Session and install rJava like this:

install.packages("rJava",type='source')

Now you should be able to install RWeka:

install.packages("RWeka")