Installing packages in R: "Java configuration variables are not set"

Dear users,
When trying to install packages in R, I get the following error. Would be great if you could help me out here.

*" 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." *

I think it has something to do with the compiler, but I am not sure. When running R CMD javareconf in root mode, I get the following information. Any suggestions on how to fix this?

*"R CMD javareconf
Java interpreter : /usr/lib64/jvm/java/jre/bin/java
Java version : 1.5.0
Java home path : /usr/lib64/jvm/java
/usr/lib64/gcc/x86_64-suse-linux/4.8/…/…/…/…/lib64/crt1.o: In function _start': /home/abuild/rpmbuild/BUILD/glibc-2.18/csu/../sysdeps/x86_64/start.S:118: undefined reference to main’
collect2: error: ld returned 1 exit status
Java compiler : not functional
Java headers gen.: /usr/lib64/jvm/java/bin/javah
Java archive tool: /usr/lib64/jvm/java/bin/jar

trying to compile and link a JNI progam
detected JNI cpp flags :
detected JNI linker flags : -L/usr/lib64/…/lib64/gcj-4.8-14 -ljvm
gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o conftest.so conftest.o -L/usr/lib64/…/lib64/gcj-4.8-14 -ljvm -L/usr/lib64/R/lib -lR

JAVA_HOME : /usr/lib64/jvm/java
Java library path: /usr/lib64/…/lib64/gcj-4.8-14
JNI cpp flags :
JNI linker flags : -L/usr/lib64/…/lib64/gcj-4.8-14 -ljvm
Updating Java configuration in /usr/lib64/R"

*Many thanks in advance!!

Hello and welcome here.

Please alwyas tell which version of openSUSE you use.

Also, when you post computer text here in a post (copied/pasted from a terminal window), do so between CODE tags. You get them by clicking on the # button in the tooll bar of the post editor.

And when you do something like “When trying to install packages in R”. do not tell the story alone, but show what you are exectly doing. Do not think that there is obvious only one way to do things and that thus everybody knows what you are doing. Often there are more ways to achieve the same and we can not guess what you do. Also when “trying”, you could make errors, but we can not see them when you do not show what you do.

Sorry for the confusion, thanks for the suggestions,

I am using SUSE 13.1. When trying to install packages in R - Konsole (

install.packages("XLConnect")

, I get the following error.

 * installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/lib64/jvm/java/jre/bin/java'
archiver    : '/usr/lib64/jvm/java/bin/jar'
compiler    : '/usr/lib64/jvm/java/bin/javac'
header prep.: '/usr/lib64/jvm/java/bin/javah'
cpp flags   : ''
java libs   : '-L/usr/lib64/../lib64/gcj-4.8-14 -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.

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

ERROR: configuration failed for package ‘rJava’
* removing ‘/home/remco/R/x86_64-suse-linux-gnu-library/3.0/rJava’
ERROR: dependency ‘rJava’ is not available for package ‘XLConnect’
* removing ‘/home/remco/R/x86_64-suse-linux-gnu-library/3.0/XLConnect’

The downloaded source packages are in
        ‘/tmp/Rtmpe5yoq8/downloaded_packages’
Warning messages:
1: In install.packages("XLConnect") :
  installation of package ‘rJava’ had non-zero exit status
2: In install.packages("XLConnect") :
  installation of package ‘XLConnect’ had non-zero exit status

I think it has something to do with the compiler, but I am not sure. When running

R CMD javareconf

in Terminal root mode, I get the following information. Any suggestions on how to fix this?

*R CMD javareconf
Java interpreter : /usr/lib64/jvm/java/jre/bin/java
Java version     : 1.5.0
Java home path   : /usr/lib64/jvm/java
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o: In function `_start':
/home/abuild/rpmbuild/BUILD/glibc-2.18/csu/../sysdeps/x86_64/start.S:118: undefined reference to `main'
collect2: error: ld returned 1 exit status
Java compiler    : not functional
Java headers gen.: /usr/lib64/jvm/java/bin/javah
Java archive tool: /usr/lib64/jvm/java/bin/jar

trying to compile and link a JNI progam 
detected JNI cpp flags    : 
detected JNI linker flags : -L/usr/lib64/../lib64/gcj-4.8-14 -ljvm
gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG  -I/usr/local/include     -fpic  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall  -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables  -fasynchronous-unwind-tables -g  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o conftest.so conftest.o  -L/usr/lib64/../lib64/gcj-4.8-14 -ljvm -L/usr/lib64/R/lib -lR

JAVA_HOME        : /usr/lib64/jvm/java
Java library path: /usr/lib64/../lib64/gcj-4.8-14
JNI cpp flags    : 
JNI linker flags : -L/usr/lib64/../lib64/gcj-4.8-14 -ljvm
Updating Java configuration in /usr/lib64/R

*

When trying to install another package through the R - Konsole I get:

> 
install.packages("plyr")
Installing package into ‘/home/remco/R/x86_64-suse-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
also installing the dependency ‘Rcpp’

trying URL 'http://cran-mirror.cs.uu.nl/src/contrib/Rcpp_0.11.1.tar.gz'
Content type 'application/x-gzip' length 2003515 bytes (1.9 Mb)
opened URL
==================================================
downloaded 1.9 Mb

trying URL 'http://cran-mirror.cs.uu.nl/src/contrib/plyr_1.8.1.tar.gz'
Content type 'application/x-gzip' length 393233 bytes (384 Kb)
opened URL
==================================================
downloaded 384 Kb

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
Warning: R include directory is empty -- perhaps need to install R-devel.rpm or similar
g++ -I/usr/lib64/R/include -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g  -c Date.cpp -o Date.o
In file included from ../inst/include/Rcpp.h:27:0,
                 from Date.cpp:31:
../inst/include/RcppCommon.h:36:15: fatal error: R.h: No such file or directory
 #include <R.h>
               ^
compilation terminated.
make: *** [Date.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/home/remco/R/x86_64-suse-linux-gnu-library/3.0/Rcpp’
ERROR: dependency ‘Rcpp’ is not available for package ‘plyr’
* removing ‘/home/remco/R/x86_64-suse-linux-gnu-library/3.0/plyr’

The downloaded source packages are in
        ‘/tmp/Rtmpe5yoq8/downloaded_packages’
Warning messages:
1: In install.packages("plyr") :
  installation of package ‘Rcpp’ had non-zero exit status
2: In install.packages("plyr") :
  installation of package ‘plyr’ had non-zero exit status

Most likely you need to install the package java-1_7_0-openjdk-devel first.


PC: oS 13.1 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.11 | GTX 650 Ti
ThinkPad E320: oS 13.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.11 | HD 3000
HTPC: oS 13.1 x86_64 | Celeron@1.8GHz | 2GB | Gnome 3.10 | HD 2500

Am 09.05.2014 19:56, schrieb Molenhuis:
> …/inst/include/RcppCommon.h:36:15: fatal error: R.h: No such file or directory

Of course you need to install R-base-devel with yast or zypper before
you can use the R package system as it often will compile some software
from the downloaded source archives.


PC: oS 13.1 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.11 | GTX 650 Ti
ThinkPad E320: oS 13.1 x86_64 | i3@2.30GHz | 8GB | KDE 4.11 | HD 3000
HTPC: oS 13.1 x86_64 | Celeron@1.8GHz | 2GB | Gnome 3.10 | HD 2500

Thanks a lot! The plyr package is now working. The XLConnect package still gave the same problem, I managed to get the job done by using a different package to import excel files.

I had the same problem on openSUSE 42.1 when installing rJava package.

In R:


> install.packages("rJava")
. . .
checking Java support in R... present:
interpreter : '/usr/lib64/jvm/jre/bin/java'
archiver    : '/usr/lib64/jvm/jre/../bin/jar'
compiler    : '/usr/lib64/jvm/jre/../bin/javac'
header prep.: '/usr/lib64/jvm/jre/../bin/javah'
cpp flags   : ''
java libs   : '-L/usr/lib64/jvm/jre/lib/amd64/server -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.

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

ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/lib64/R/library/rJava’

The downloaded source packages are in
        ‘/tmp/RtmpLZqJ3r/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rJava") :
  installation of package ‘rJava’ had non-zero exit status

In console as root:


# R CMD javareconf
Java interpreter : /usr/lib64/jvm/jre/bin/java
Java version     : 1.8.0_101
Java home path   : /usr/lib64/jvm/jre
Java compiler    : /usr/lib64/jvm/jre/../bin/javac
Java headers gen.: /usr/lib64/jvm/jre/../bin/javah
Java archive tool: /usr/lib64/jvm/jre/../bin/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : 
detected JNI linker flags : -L/usr/lib64/jvm/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o conftest.so conftest.o -L/usr/lib64/jvm/jre/lib/amd64/server -ljvm -L/usr/lib64/R/lib -lR


JAVA_HOME        : /usr/lib64/jvm/jre
Java library path: /usr/lib64/jvm/jre/lib/amd64/server
JNI cpp flags    : 
JNI linker flags : -L/usr/lib64/jvm/jre/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib64/R
Done.

I followed this post:


# unset JAVA_HOME
# R CMD javareconf
Java interpreter : /usr/bin/java
Java version     : 1.8.0_101
Java home path   : /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/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 -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/../include -I/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/../include/linux -I/usr/local/include    -fpic  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o conftest.so conftest.o -L/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/amd64/server -ljvm -L/usr/lib64/R/lib -lR


JAVA_HOME        : /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib64/R
Done.

Then rJava has been installed successfully.