When installing rJava using the install.packages(\"rJava\")
command I get the following error:
checking Java support in R... present:
interprete
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.
The problem was rJava wont install in RStudio
(Version 1.0.136
). The following worked for me (macOS Sierra version 10.12.6
) (found here):
Step-1: Download and install javaforosx.dmg
from here
Step-2: Next, run the command from inside RStudio:
install.packages("rJava", type = 'source')
On Arch Linux, I needed to install openjdk-src
to get a JNI path working.
In other words, these are the packages I needed to install before sudo R CMD javareconf
ran successfully:
local/jdk-openjdk 14.0.2.u12-1
OpenJDK Java 14 development kit
local/jre-openjdk 14.0.2.u12-1
OpenJDK Java 14 full runtime environment
local/jre-openjdk-headless 14.0.2.u12-1
OpenJDK Java 14 headless runtime environment
local/openjdk-src 14.0.2.u12-1
OpenJDK Java 14 sources
That is how I make it work :
sudo apt-get install default-jre
sudo apt-get install default-jdk
sudo R CMD javareconf
install.packages("rJava")
I was facing the same problem while using Windows 10. I have solved the problem using the following procedure
Note: jdk1.8.0_201 and jre1.8.0_201 will be changed depending on the version of Java development kit and Java
To check the installation, open CMD\Type javac\Press Enter and Type java\press enter It will show
In RStudio run
Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jdk1.8.0_201")
Note: jdk1.8.0_201 will be changed depending on the version of Java development kit
Now you can install and load rJava package without any problem.
below is one of my answers on another post - error: unable to load installed packages just now
(this is also relevant to this question)
For Linux(Ubuntu) users: If you have oracle-java (7/8) installed. It'll be at this location /usr/lib/jvm
and sudo
access is required.
Create the file /etc/ld.so.conf.d/java.conf
with the following entries:
/usr/lib/jvm/java-8-oracle/jre/lib/amd64
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
(Replace java-8-oracle with java-7-oracle depending on your java version)
Then:
sudo ldconfig
Restart RStudio and then install the rJava package.