error initializing packrat on Rstudio server (ubuntu)

I'm trying to initialize packrat for a project. I click on packages pane and check packrat box that says "use packrat with this project . I get an error at the end of the process.

Error: Command failed (1)

Failed to run system command:

	'/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/Rtmpm3FonH/rJava' --library='/home/joe/R/project4/packrat/lib/x86_64-pc-linux-gnu/3.4.4' --install-tests --no-docs --no-multiarch --no-demo 

The command failed with output:
* installing *source* package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked
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... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI

checked if rJava and JDK is installed:

rjava

 java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

so I run the command again on terminal:

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.

then followed the instructions and run "R CMD javareconf"

Java interpreter : /usr/lib/jvm/default-java/jre/bin/java
Java version     : 1.8.0_181
Java home path   : /usr/lib/jvm/default-java
Java compiler    : not present
Java headers gen.:
Java archive tool:

trying to compile and link a JNI program
detected JNI cpp flags    :
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: Not found file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:159:failed instructions for target 'conftest.o'
make: *** [conftest.o] Error 1
Unable to compile a JNI program

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.