Installing rJava in R>=3.0

This is just a blog post for me to remember this hack that bother for some time, if it can help other people this is even better.

So for some time I had this issue with rJava when I was running:

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.

So I could not install this much needed package, after some roaming over the internet I found this post:   and this one:

And  so I followed their advice and this what I ended up doing in my terminal:

gksudo gedit /etc/environment %This open a new gedit window I added the line: JAVA_HOME =”/usr/lib/jdm/” %check that this is your path as well using cd and ls
Saved the file and to check if this worked:


Then back in R you can run the usual install.packages() command and it completed successfully for me.



3 thoughts on “Installing rJava in R>=3.0

  1. Experienced the same when trying to install rJava in R version 3.2.2 :
    “Make sure R is configured with full Java support (including JDK). Run R CMD javareconf as root to add Java support to R.

    If you don’t have root privileges, run R CMD javareconf -e
    to set all Java-related variables and then install rJava.”

    The message persists after running R CMD javareconf -e , or R CMD javareconf as root.

    The message is issued by the rJava configure script after testing whether various java environment variables do have non-zero length ( if test -n “${JAVA}” && … ). The test fails for JAVA_CPPFLAGS .

    Remedy: Create the environment variable JAVA_CPPFLAGS manually to consist of just one blank:

    C-Shell: setenv JAVA_CPPFLAGS ” ”

    BASH: export JAVA_CPPFLAGS=” ”

    (Don’t forget the blank between the quotes.)

    Good luck!

  2. Adding this to my previous comment: Defining JAVA_HOME ( /usr/lib64/jvm/jre under SuSE Linux, version Leap 42.1), as recommended in the original post didn’t do the trick for me, but thanks for the recommendation anyway!

    The environment variables tested by the configure script are: JAVA JAVAC JAVAH JAVA_CPPFLAGS JAVA_LIBS JAR . If only one of them has zero length, the script stops with the infamous error message.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s