Installing rJava in Jupyter R Notebook

Hi All,

I’m new to Jupyter Notebook and I have Docker jupyter/datascience-notebook installed on my PC.
I’m struggling to install rJava packages in Notebook.

I can install it fine if I start the R terminal with sudo.
But without sudo i’m getting same error which is the same in the notebook.

Error Message from Notebook

Warning message in install.packages(“rJava”, “/opt/conda/lib/R/library”):
installation of package ‘rJava’ had non-zero exit status”
Updating HTML index of packages in ‘.Library’

Making ‘packages.html’ …

Error Message from R terminal without sudo

trying URL ‘
Content type ‘application/x-gzip’ length 664898 bytes (649 KB)
downloaded 649 KB

** installing source package ‘rJava’ …*
*** package ‘rJava’ successfully unpacked and MD5 sums checked*
*** using staged installation*
checking for gcc… x86_64-conda_cos6-linux-gnu-cc
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 x86_64-conda_cos6-linux-gnu-cc accepts -g… yes
checking for x86_64-conda_cos6-linux-gnu-cc option to accept ISO C89… none needed
checking how to run the C preprocessor… x86_64-conda_cos6-linux-gnu-cc -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 x86_64-conda_cos6-linux-gnu-cc supports static inline…
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/bin/java’
archiver : ‘/usr/bin/jar’
compiler : ‘/usr/bin/javac’
header prep.: ‘’
cpp flags : ‘-I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux’
java libs : ‘-L/usr/lib/jvm/java-11-openjdk-amd64/lib/server -ljvm’
checking whether Java run-time works… yes
checking whether -Xrs is supported… yes
checking whether -Xrs will be used… yes
checking whether JVM will be loaded dynamically… no
checking whether JNI programs can be compiled… configure: error: Cannot compile a simple JNI program. See config.log fordetails.

Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run “R CMD javareconf” as root.

ERROR: configuration failed for package ‘rJava’
** removing ‘/opt/conda/lib/R/library/rJava’*

The downloaded source packages are in

  •    ‘/tmp/RtmpGfk7Iy/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*

I have tried various different options on stackexchange as well as running numerous time of “R CMD javareconf” without success.

I guess my question is that is there any option to start the R notebook with sudo option please?

Many Thanks