Ubuntu – Correct Installation and configuration of openJDK and R


I am relatively new to Ubuntu so I wont know a lot of commands that probably became standard to a lot of you guys.
I am trying to set up R and with it the necessary java dependencies to install e.g. JGR, rjava, etc. I read through quite a few instructions to do that but somehow I must have done sth wrong. Here is the state of R and java:

R --version

R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

java -version

java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.1)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

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: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
JNI linker flags : -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
JNI cpp flags    : 

But when I try to install 'JavaGD' in R, which is a dependency for JGR I get:

checking Java support in R... present:
interpreter : '/usr/bin/java'
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: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

Any help would be greatly appreciated. Thanks!

Best Answer

  • I'm not familiar with R but based on your console it seems like R is requiring a JDK while you have a JRE as you default JAVA home variable. I would suggest you to make sure you have the JDK installed or install it (sudo apt-get install openjdk-6-jdk).
    Also make sure that your JAVA_HOME environment variable is pointing to the JDK and not to the JRE (you can see in your output that currently the java home path is set to /usr/lib/jvm/java-6-openjdk/jre.

  • Related Question