R: Rjava Package Install Failing

R: rJava package install failing

Turns out my problem was an issue with my JAVA_HOME environment variable. Yes, shocking I know. My initial setting for PATH and JAVA_HOME looked like this:

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

And I added /jre so it now looks like this:

export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
export PATH=$PATH:$JAVA_HOME/bin

Everything in Java seemed to work fine without the /jre but rJava would not. Odd.

configuration failed for package ‘rJava’ when running rize - R

It looks like you have issues with setting proper location of Java. Note that making R happy with Java might be a little bit of struggle.

Take a look here: http://www.owsiak.org/r-java-11-and-making-sure-you-can-load-rjava/ for a sample. It is macOS based, but still, it should work fine.

Basically, what you want to do is to set your JAVA_HOME such way it points at Java installation. Once it's done, you can run R cmd javareconf like this

> sudo R CMD javareconf \
JAVA_HOME=${JAVA_HOME} \
JAVA=${JAVA_HOME}/bin/java \
JAVAC=${JAVA_HOME}/bin/javac \
JAVAH=${JAVA_HOME}/bin/javah \
JAR=${JAVA_HOME}/bin/jar

Make sure you have gcc installed and that you can compile simple C code.

ERROR: configuration failed for package 'rJava'

I changed environment path from

JAVA_HOME: C:\Users\H481821\Downloads\openjdk-18.0.1.1_windows-x64_bin
to
C:\Users\H481821\Downloads\openjdk-18.0.1.1_windows-x64_bin\jdk-18.0.1.1

and executed R cmd

install.packages("rJava", type="win.binary")

(Use this to get compatible package to you R version so that you won't face version issues)



Related Topics



Leave a reply



Submit