Install rJava package in R

Recently, it took my lot of time in installation of the rJava package in R. I am on Ubuntu 16.04, 64-bit system, so I thought let me document all the things which I have done. Although, all the information is present in the internet but it is scattered and it took lot of time to gather all the information which is relevant to me. So bringing everything under one roof.

I was trying to install xlsx package in R when it gave me an error stating that

Loading required package: rJava

Anyways, as I also wanted to install rJava, I moved to install rJava package. While installing rJava it gave me an error now stating,

ERROR: configuration failed for package ‘rJava’ * removing ‘/home/ronakshah/R/x86_64-pc-linux-gnu-library/3.2/rJava

I thought , maybe Java isn’t install on my system. So let me try installing it first.

sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk

This was still giving me the same error installing Java. After a lot of google searches and trial and errors did, finally this worked

sudo apt-get install r-cran-rjava

After this another error which I was stuck into was,

configure: error: Cannot compile a simple JNI program. See config.log for details. Make sure you have Java Development Kit installed and correctly registered in R. If in doubt, re-run "R CMD javareconf" as root.

To resolve I just used the command shown in the error.

sudo R CMD javareconf

after which I was finally able to install both xlsx and rJava package.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s