How to Install Rjava in R 3.0 in Ubuntu 13.04

Unable to install rJava in R 3.0 in Ubuntu 13.04

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.

Why does rJava not work on Ubuntu 14.04 using OpenJDK 7?

I had the same problem with a similar configuration (R 3.1.0, Ubuntu 12.10, 32-bit). I found the answer was in getting LD_LIBRARY_PATH set properly, as described here:
error: unable to load installed packages just now except that the subdirectory in question is 'client' not 'server'. So now I'm setting my environment like this:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client

Installation of rJava

You don't seem to have JDK installed. You will need at least

sudo apt-get install openjdk-7-jdk

then re-run

sudo R CMD javareconf

Make sure you do NOT set JAVA_HOME by hand - it will be detected automatically. You should then see something like this:

$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.7.0_91
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

trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/lib/jvm/java-7-openjdk-amd64/jre/../include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server -ljvm -L/usr/lib/R/lib -lR

JAVA_HOME : /usr/lib/jvm/java-7-openjdk-amd64/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/../include
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm

R - install rJava on RStudio - Amazon Cloud

I found the answer here. I should use PUTTY terminal to connect to the instance commandline:
http://www.louisaslett.com/RStudio_AMI/

Can't install rJava on ubuntu system

The easiest way to get rJava on Ubuntu is to install it from the repositories instead of trying to install it directly from CRAN. From the command line this should do the trick

sudo apt-get install r-cran-rjava

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.

Unable to run a simple JNI program error message when installing rJava on R 3.6 for ubuntu bionic beaver

I've investigated with the original poster (we work at the same place) and the problem is that in OpenJDK11 they moved around some of the .so files that the JVM lives in, specifically libjvm.so which in the Ubuntu package is now in /usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/server/.

This means that even if you install the Ubuntu package for rJava with apt install r-cran-rjava it fails when you try to library(rJava).

The solution is to add /usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/server/ to your $LD_LIBRARY_PATH by adding:

export LD_LIBRARY_PATH=/usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/server:$LD_LIBRARY_PATH

to the end of your ~/.bashrc and starting a new shell (or source ~/.bashrc).

This is something we had to fix for our central installs of OpenJDK e.g. here: https://github.com/UCL-RITS/rcps-buildscripts/blob/master/adoptopenjdk-11.0.3_install.sh#L46

If you want to make this work with Rstudio launched from Gnome, you need to add that directory to ldconfig.

As root (or with sudo) create a file in /etc/ld.so.conf.d/ which you should call something with a .conf extension e.g. java.conf which contains the line:

/usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/server

And then as root run

ldconfig -v

This should add the directory to the locations that executables launched through GNOME search for. This particular part of the problem (GNOME ignoring settings in bashrc) has been a problem in Ubuntu since at least 9.04 (https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/366728/).



Related Topics



Leave a reply



Submit