Skip to content

help updating package rJava (on ubuntu)

7 messages · Simon Urbanek, Hasan Diwan, Karl Brand

#
Esteemed useRs and Devs,

Attempts to update package:rJava to the latest version have failed. See 
my code and output below.

Notably, as suggested here 
http://stackoverflow.com/questions/3311940/r-rjava-package-install-failing

$ sudo apt-get install r-cran-rjava

ran successfully without error or warning, but my rJava package is not 
updated, and remains un-updatable...

Greatly appreciate any suggestions getting my rJava updated,

Karl



 > update.packages(lib.loc = "/usr/lib/R/site-library")
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
rJava :
  Version 0.9-1 installed in /usr/lib/R/site-library
  Version 0.9-3 available at http://cran.xl-mirror.nl
Update (y/N/c)?  y

<snip>

checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver    : ''
compiler    : ''
header prep.: ''
cpp flags   : ''
java libs   : '-L/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server 
-L/usr/lib/jvm/java-6-openjdk/jre/lib/amd64 
-L/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64 
-L/usr/java/packages/lib/amd64 -L/usr/lib/jni -L/lib -L/usr/lib -ljvm'
configure: error: Java Development Kit (JDK) is missing or not 
registered in R
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

...so i do as suggested:

$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version     : 1.6.0_23
Java home path   : /usr/lib/jvm/java-6-openjdk/jre
Java compiler    : not present
Java headers gen.:
Java archive tool:
Java library path: 
$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server 
-L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 
-L/usr/java/packages/lib/amd64 -L/usr/lib/jni -L/lib -L/usr/lib -ljvm
JNI cpp flags    :

Updating Java configuration in /etc/R
Done.

But i still get the same error when trying to update rJava!

 > sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_AU.UTF-8
  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_AU.UTF-8
  [7] LC_PAPER=C                 LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
#
On Feb 18, 2012, at 10:44 AM, Karl Brand wrote:

            
Obviously - your'e lacking JDK on your machine - see the output above (you have only JRE, not JDK). If you want to compile rJava form sources you need to install JDK first, then add Java support to R (via javareconf) and then build rJava.

Cheers,
Simon
#
Simon,

Thanks for yout fast response. Thing is - i managed to get Version 0.9-1 
installed and fully functional. And

$ locate jdk

returns too many entries to post here, so i'm pretty sure its on the 
machine.

So i'd like to know how i can ensure it's "registered in R". This i have 
no idea how to do. I simply don't have enough R and linux experience. 
Also the thread i mentioned 
http://stackoverflow.com/questions/3311940/r-rjava-package-install-failing

seems to be about pointing R at the right location of certain aspects of 
Java. But lacks enough explicit details for myself to be able use.

Thanks again, also for any further suggestions,

Karl
On 02/18/2012 07:45 PM, Simon Urbanek wrote:

  
    
#
On 18 February 2012 13:13, Karl Brand <k.brand at erasmusmc.nl> wrote:
What you want to look for is javac, not jdk. On my ubuntu system, this
is to be found at /usr/lib/jvm/java-6-openjdk-i386/bin/javac
A previous response indicated R javareconf -- this is the only
configuration you should need. Let me know if you have further
problems.
1 day later
#
Hi Hasan,

Success. For myself and FWIW to other useR's here's how i spent the 
sunny half of my sunday to achieve it :/

Many thanks for your and Simon's input,

Karl

Since:

$ javac -version

returned nothing i believe you (and Simon) were right, i.e, it (and JDK) 
were missing on my system. Furthermore:

$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version     : 1.6.0_23
Java home path   : /usr/lib/jvm/java-6-openjdk/jre
Java compiler    : not present
Java headers gen.:
Java archive tool:
Java library path: 
$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server 
-L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 
-L/usr/java/packages/lib/amd64 -L/usr/lib/jni -L/lib -L/usr/lib -ljvm
JNI cpp flags    :

Updating Java configuration in /etc/R
Done.

Some things are clearly absent i.e.,
Java compiler    : not present
Java headers gen.:
Java archive tool:

Now i have:

$ javac -version
javac 1.6.0_23

$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version     : 1.6.0_23
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
Java library path: 
$(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server 
-L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 
-L/usr/java/packages/lib/amd64 -L/usr/lib/jni -L/lib -L/usr/lib -ljvm
JNI cpp flags    : -I$(JAVA_HOME)/../include

Updating Java configuration in /etc/R
Done.

Certainly i don't know exactly what was needed to achieve this. BUT - 
for posterities sake, this is what i did:

## purge and reinstall openjdk-6-jdk which turned outwasn't installed!
## how this can be when i have a /usr/lib/jvm/java-6-openjdk full of
## files i don't understand. Moreover since i had the previosu version
## of rJava running fine!!!
$ sudo apt-get purge openjdk-6-jdk
<snip>
Package openjdk-6-jdk is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

## install openjdk-6-jdk
$ sudo apt-get install openjdk-6-jdk

## Per- http://ubuntuforums.org/showthread.php?t=1491846
## added 2 entries to /etc/bash.bashrc file
$ gksudo gedit /etc/bash.bashrc

## entries were:
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/jre
export PATH=$PATH:$JAVA_HOME/bin

## note the addition of /jre for JAVA_HOME per-
## 
http://stackoverflow.com/questions/3311940/r-rjava-package-install-failing

<saved bash.bashrc file then reloaded>

$ source /etc/bash.bashrc

## confirmed
$ echo $JAVA_HOME
/usr/lib/jvm/java-6-openjdk/jre

## configured java
$ sudo R CMD javareconf

I was then able to update rJava in a new R-session.

Also note that per- 
http://stackoverflow.com/questions/3311940/r-rjava-package-install-failing

$ apt-get install r-cran-rjava

did NOT enable me to update my rJava. Unless i buggered up something 
else along the way :/
On 02/18/2012 10:20 PM, Hasan Diwan wrote:

  
    
#
On Feb 19, 2012, at 4:31 PM, Karl Brand wrote:

            
FWIW you should not need to set any custom settings if you system is properly configured (if you use Java 1.7 you may need R 2.14.0 or higher which works around some bugs in 1.7 binaries). On Debian/Ubuntu you just install your favorite JDK (Sun/Oracle or OpenJDK) and use 'sudo update-alternatives --config java' or 'sudo update-java-alternatives' (depending on the age of your system) to select the right one.

The fact you you had to tweak PATH means that something is seriously broken or you did setup the alternatives configuration correctly.

Cheers,
Simon
#
Simon,

Thanks alot for the further clarification. As i said some where in my 
lengthy explanation - i don't what of the myriad steps were needed, only 
that they were performed and i now have an up-to-date rJava.

Next time (actually coming up soon) i'll certainly be following the 
couple simple steps you suggest. Also good to know that Java 1.7 can be 
used with the latest R (which is all i intend to install).

Thanks again for the follow up,

Karl
On 02/20/2012 03:37 AM, Simon Urbanek wrote: