When installing rJava using the install.packages("rJava")
command I get the following error:
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver : '/usr/bin/jar'
compiler : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags : '-I/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../include -I/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../include/linux'
java libs : '-L/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64/server -L/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64 -L/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/amd64 -L -L/usr/java/packages/lib/amd64 -L/usr/lib64 -L/lib64 -L/lib -L/usr/lib -ljvm'
checking whether JNI programs can be compiled... yes
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package ‘rJava’
I have the Java JDK installed and java -version
returns the following:
$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
When Googling around for the error I see that others are having the same issue but not finding a solution other than "install the whole JDK, not just the JRE" which I have done.
The other thing I read was to run sudo R CMD javareconf
which runs quite happily with no errors.
Any ideas what my problem is?
[[EDIT]] It's been a few months since I had this problem. I had initially solved this by editing my Java paths, as illustrated in the answer I posted below. I recently ran into the same issue on a new Ubuntu install. I tried Dirk's recommendation to use apt-get to install the rJava package. It worked perfectly. What I failed to appreciate initially is that installing packages using the Ubuntu apt-get method is fundamentally different than just loading the same package using install.packages() inside of R. The Ubuntu packages solve some issues which I didn't realize or appreciate.
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
andsudo
access is required.Create the file
/etc/ld.so.conf.d/java.conf
with the following entries:(Replace java-8-oracle with java-7-oracle depending on your java version)
Then:
Restart RStudio and then install the rJava package.
I got it working by downloading : https://cran.r-project.org/src/contrib/rJava_0.9-8.tar.gz and running command R CMD install rJava_0.9-8.tar.gz
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 hereStep-2: Next, run the command from inside RStudio:
Wouldn't
have been easier? You could have asked me at useR! :)
I've encountered similar problem on Ubuntu 16.04 and was able to solve it by creating a folder named "default-java" in
/usr/lib/jvm
and copying into it all the contents of the/usr/lib/jvm/java-8-oracle
. I opted for this solution as correcting JAVA_HOME environment variable turned out to be of no use.Running R under Gentoo on an AMD64. I upgraded to R 2.12.0
R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit) and those pesky messages went away.
Jan Vandermeer