I am experiencing the same rJava problem that many other people seem to of had at one point or another. The error occurs when R CMD INSTALL tests whether JNI programs can be compiled.
The output recommends running R CMD javareconf -ed or sudo R CMD javareconf The output of the latter is :
computer: home$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.6.0_31
Java home path : /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Java library path:
JNI linker flags : -framework JavaVM
JNI cpp flags : -I$(JAVA_HOME)/include
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
And when trying to install rJava afterwards,
computer: home$ R CMD INSTALL ~/Downloads/rJava_0.9-4.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library’
* installing *source* package ‘rJava’ ...
checking for gcc... gcc -arch x86_64 -std=gnu99
checking for C compiler default output file name... a.out
/* Passes all checks */
configure: checking whether gcc -arch x86_64 -std=gnu99 supports static inline...yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
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/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include'
java libs : '-framework JavaVM'
checking whether JNI programs can be compiled... configure: error: Cannot compile a simple JNI program. See config.log for details.
Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run "R CMD javareconf" as root.
ERROR: configuration failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/2.15/Resources/library/rJava’
An alternative attempt where /usr/bin/javac is replaced by /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Homefails just the same.
I am running Mac OS 10.7.3 and
computer: home$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3646)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01-415, mixed mode)
The following is in my .bash_profile
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Additionally, I have the same problem on Red-Hat. I hope any fix provided will work there too, but if it won't and why it won't is know, please explain.
I've been using this site's incredible knowledge base for a couple of years now, but this is my first post. Mucho thanks in advance.
Some (not all) of the resources I have already browsed through are
https://stat.ethz.ch/pipermail/r-devel/2008-November/051224.html
https://stat.ethz.ch/pipermail/r-help/2008-October/177688.html
R: rJava package install failing
Please note that the apt-get solution in the last link is of no use to me (I think) unless there is an equiv solution for port and/or yum.
I am using Redhat Linux 7.1
I was getting the same problem as above and I performed the following steps
1) Edit /usr/lib64/R/etc/Renviron and add "CPPFLAGS=${CPPFLAGS-'-ldl'}" to the end of the file
2) Then find the java home and set it like below ( set java home till /jre)
$export JAVA_HOME=/usr/lib/jvm/java-1.7.1-ibm-1.7.1.3.10-1jpp.1.el7_1.x86_64/jre
$export PATH=$PATH:$JAVA_HOME/bin
$R CMD javareconf
3) invoke R from commandline
$R
> install.packages("rJava")
> install.packages("RJDBC",dep=TRUE)
> q()
Save workspace image? [y/n/c]: y
I had a recent variation on this same problem with RHEL 6.5. I reviewed this thread and many others. The ptoblem was that the dynamic load modules were not found when testing the complile of the JNI programs. My fix was to insert "CPPFLAGS=${CPPFLAGS-'-ldl'}" into file
/usr/lib64/R/etc/Renviron
Related
I am having issues installing R packages in a conda environment on MacOS 10.15.4. The command install.packages() in R leads to the following type of errors (I am not pasting the full log):
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
Error 1
ERROR: compilation failed for package ‘xml2’
checking for gcc... x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/k6/p2cdz1dx32g3p4hmwghns3fc0000gn/T/RtmpdPz2VA/R.INSTALL4817a82715f/uuid':
configure: error: C compiler cannot create executables
I am using r version 3.6.1 on a platform x86_64-apple-darwin13.4.0
The clang version is:
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /opt/anaconda3/envs/r_omics/bin
So I assumed there was an issue/conflict with the way the C compilers on my computer process R-packages installation but I don't know how to solve this.
Somehow I manage to install some of the packages through conda install but I don't manage through this to recover the environment I need.
Thank you very much for your help
Where does rJava take location of JDK from ? I have JAVA_HOME set but on install.packages("rJava") I get this
checking Java support in R... present:
interpreter : '/usr/lib/jvm/default-java/jre/bin/java'
archiver : '/usr/lib/jvm/default-java/bin/jar'
compiler : '/usr/lib/jvm/default-java/bin/javac'
header prep.: '/usr/lib/jvm/default-java/bin/javah'
cpp flags : '-I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux'
java libs : '-L/usr/lib/jvm/default-java/jre/lib/amd64/server -ljvm'
checking whether Java run-time works...
./configure: line 3736: /usr/lib/jvm/default-java/jre/bin/java: No such file or directory
no
configure: error: Java interpreter '/usr/lib/jvm/default-java/jre/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
I can't figure out where it takes /usr/lib/jvm/default-java/ from.
From R which stores this when it is configured:
edd#max:~$ grep ^JAVA /etc/R/Makeconf
JAVA = /usr/lib/jvm/default-java/jre/bin/java
JAVAC = /usr/lib/jvm/default-java/bin/javac
JAVAH = /usr/lib/jvm/default-java/bin/javah
JAVA_HOME = /usr/lib/jvm/default-java
JAVA_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JAVA_LIBS = -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
JAVA_LD_LIBRARY_PATH = $(JAVA_HOME)/jre/lib/amd64/server
edd#max:~$
If you update your Java toolchain you can update this via R CMD javareconf.
I am not able to call rJava package in R 3.0. I got the following message
Error: package ‘rJava’ was built before R 3.0.0: please re-install it
I am getting error when I tried to re-install rJava package. I have provided the output of R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.7.0_21
Java home path : /usr/lib/jvm/java-7-openjdk-i386/jre
Java compiler : /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/javac
Java headers gen.: /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/javah
Java archive tool: /usr/lib/jvm/java-7-openjdk-i386/jre/../bin/jar
trying to compile and link a JNI progam
detected JNI cpp flags :
detected JNI linker flags :
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O2 -pipe -g -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
compilation terminated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
I am using Ubuntu 13.04. I also tried apt-get install r-cran-rjava which is not helping to solve the issue. Regarding jni.h there were some solution here. But, not sure how can I use the solution here.
I ran into the exact same issue. My solution was to install the openjdk-7-* via
sudo apt-get install openjdk-7-*
Followed that with
sudo R CMD javareconf
and I was then able to install rJava in R via install.packages("rJava").
While perhaps not the most elegant solution it appears to have solved my problems with getting rJava to work.
For those getting the error:
error: unable to load shared object '/some/dir/rJava/libs/rJava.so': libjvm.so:
cannot open shared object file: No such file or directory
I solved the error locating the library in the system and linking them to /usr/lib:
$sudo updatedb
$locate libjvm.so
/usr/lib/debug/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/debug/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/zero/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/jamvm/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/zero/libjvm.so
$sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so /usr/lib/
Installing rJava from the distribution packages as proposed in this askUbuntu answer also works:
sudo apt-get install r-cran-rjava
NOTE: tried from a Debian system.
I was also facing same error which was on RHEL8.1 & i resolved it as follows:
yum --enablerepo=* install java-1.8*
later i ran same command which was giving me error logs of R server.
R CMD javareconf
which turns into following output.
I'm trying to install unix package on windows environment. I'm using Cygwin, but its still not working.
Below is a snippet of the error I'm getting:
$ cabal install unix
Resolving dependencies...
Configuring unix-2.7.0.0...
Warning: Unknown extensions: CApiFFI, InterruptibleFFI
configure: WARNING: unrecognized options: --with-compiler, --with-gcc
checking for gcc... gcc
.
.
.
configure: creating ./config.status
config.status: creating unix.buildinfo
config.status: creating include/HsUnixConfig.h
configure: WARNING: unrecognized options: --with-compiler, --with-gcc
cabal.exe: Package unix-2.7.0.0 can't be built on this system.
Failed to install unix-2.7.0.0
cabal.exe: Error: some packages failed to install:
unix-2.7.0.0 failed during the building phase. The exception was:
ExitFailure 1
Cygwin is a partial linux toolset for windows, it's great if you need basic things but installing a full blown unix cabal plugin might be beyond its capabilities.
You may want to install a full linux os on a virtual machine (vagrant does great with this) or use a cloud real unix machine.
Linux hosts are really great to work with from remote
Happy codding
After updating to R 3.0.1 on a Debian 64-bit machine, the rJava package does not want to install.
configuration failed, so sudo R CMD javareconf [this worked on another debian machine]. however it does not work here, has anybody else had this problem? [see terminal output below]
henk#crunchbang:~$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.6.0_18
Java home path : /usr/lib/jvm/java-6-openjdk/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI progam
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O3 -pipe -g -c conftest.c -o conftest.o
conftest.c:1:17: error: jni.h: No such file or directory
conftest.c: In function ‘main’:
conftest.c:4: warning: implicit declaration of function ‘JNI_CreateJavaVM’
make: *** [conftest.o] Error 1
Unable to compile a JNI program
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib64/R
Done.
# check java
henk#crunchbang:~$ java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze2)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
java environment:
henk#crunchbang:~$ aptitude search "?provides(java-runtime)"
i A default-jre - Standard Java or Java compatible Runtime
i A default-jre-headless - Standard Java or Java compatible Runtime (headle
p gcj-4.4-jre - Java runtime environment using GIJ/classpath
p gcj-4.4-jre-headless - Java runtime environment using GIJ/classpath (he
p gcj-jre - Java runtime environment using GIJ/classpath
p gcj-jre-headless - Java runtime environment using GIJ/classpath (he
i A openjdk-6-jre - OpenJDK Java runtime, using Hotspot JIT
i A openjdk-6-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headles
i sun-java6-jre - Sun Java(TM) Runtime Environment (JRE) 6 (archit
I took these steps (on an EC2 with Ubuntu 14.04 and RStudio-Server) to install the R package qdap which requires rJava:
(I'm probably quoting other sources here and there and I don't remember from where, but thanks.)
Install these repositories from http://sites.psu.edu/theubunturblog/cran2deb4ubuntu/
(debian: http://r-forge.r-project.org/projects/cran2deb/)
sudo add-apt-repository ppa:marutter/rrutter
sudo add-apt-repository ppa:marutter/c2d4u
sudo apt-get update
Install Java:
sudo apt-get install openjdk-7-jdk
ls /usr/lib/jvm
Set a system-wide environment variable for Java:
sudo joe /etc/profile.d/javaenvvar.sh
which contains:
# JAVA environment variable
# for openjdk-7-jdk in order to use the R package `qdap`.
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
export PATH=$PATH:$JAVA_HOME/bin
Then exit BASH and sign in again. Check your path changes:
echo $PATH
echo $JAVA_HOME
Then:
sudo R CMD javareconf
Should return:
Java interpreter : /usr/bin/java
Java version : 1.7.0_65
Java home path : /usr/lib/jvm/java-7-openjdk-amd64/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Create the file /etc/ld.so.conf.d/java.conf with the following entries:
/usr/lib/jvm//usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64
/usr/lib/jvm//usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server
Then install rJava from those new repositories:
sudo apt-get install r-cran-rjava
That just installed rJava to /usr/lib/R/site-library which is accessible to all users of RStudio-Server, hopefully.
sudo update-alternatives --config java
Hopefully, there's only one java installed.
Update R packages:
sudo R
> packageStatus()
> update.packages()
Install R packages system wide (still within sudo R):
> install.packages("qdap", lib="/usr/lib/R/site-library")
Reset RStudio-Server:
Sign out of RStudio-Server first.
sudo rstudio-server stop
sudo rstudio-server start
Sign back in to RStudio-Server.
If you get a memory error, try detaching some packages.
The EC2 t2-micro has only 1 GB of RAM.
I had the same problem, the solution was updating to openjdk-7-* and use update-alternatives --config java to set the java-7-openjdk path.