[R] Problem with rJava
Ruediger Port
ruediger.port at gmail.com
Wed Jun 22 11:50:57 CEST 2016
Hit the same error message when trying install.packages('rJava')
in R 3.2.2 under SuSE Linux, version Leap 42.1 :
------------ Begin of error message ------------------------------------
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.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
------------ End of error message --------------------------------------
Neither one of "R CMD javareconf" or "R CMD javareconf -e" did help.
(Command has to be given within the same terminal window where the package
installation is tried - yet, no help.)
Remedy in my case:
------------------
setenv JAVA_CPPFLAGS " " (c-shell)
or export JAVA_CPPFLAGS=" " (bash)
Explanation, as far as I found out:
-----------------------------------
The install.packages() command downloads the rJava package,
e.g. rJava_0.9-8.tar.gz , somewhere under /tmp . If you open it
( tar xvfz /tmp/Rtmp ... rJava_0.9-8.tar.gz ) you'll find
a "configure" script which is started by install.packages()
and issues all those messages "checking for ...". The infamous
error message is found in the configure script following a line
where it tests whether all of these Java environment variables
exist and do have non-zero length:
JAVA JAVAC JAVAH JAVA_CPPFLAGS JAVA_LIBS JAR
If one of these doesn't exist or has zero length, the script
stops with the error message. The one that was missing
in my case was JAVA_CPPFLAGS . Setting it to consist
of just one blank did the trick (see above). With that,
the configure script ran successfully, as did the subsequent
installation.
With this, the configure script runs smoothly,
as does > install.packages('rJava').
Good luck!
Ruedi
More information about the R-help
mailing list