16

I have installed R on a Debian Wheezhy. I want to install rjava package, but I get this error:

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.

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

There is Java on my Linux, If I type Java -Version I see:

java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b24-1.11.5-1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

How can I solve this problem?

Kaja
  • 2,962
  • 18
  • 63
  • 99

2 Answers2

24

I have solved the problem using this command - shown in error description:

sudo R CMD javareconf
jrpereirajr
  • 361
  • 2
  • 9
  • 8
    If you get an error you might need to install the following libraries `sudo apt install default-jdk default-jre` (as explained in this [post](https://shahronak47.wordpress.com/2016/12/29/install-rjava-package-in-r/) – llrs Apr 29 '19 at 09:39
15

I had a similar problem while installing xlsx package that has some dependencies maybe related to java and r java packages...

In order to solve your problem you have to: - check environment variables $JAVA_HOME and $PATH - sudo R CMD javareconf

If it doesn't help, try out my configuration with java-7-oracle,

  • install java-7-oracle via webupd8 repository Installing Java 7 (Oracle) in Debian via apt-get
    • set environment variables $JAVA_HOME and $PATH
    • export JAVA_HOME=/usr/lib/jvm/java-7-oracle
    • export PATH=$PATH:$JAVA_HOME/bin
  • sudo update-java-alternatives -s java-7-oracle
  • sudo R CMD javareconf

and than retry the installation of rjava

I hope it will help you!

Community
  • 1
  • 1
Fabio Ciotoli
  • 165
  • 1
  • 6