3

I am trying to install the package rJava in R on Arch Linux.

I got the error:

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.

Running sudo R CMD javareconf, I can see that Java headers gen.: is not set, but I have failed to figure out how to set it.

Here is the full java configuration seen by R (beside Java haders gen., the rest looks ok to me):

Java interpreter : /usr/bin/java
Java version     : 10
Java home path   : /usr/lib/jvm/java-10-openjdk
Java compiler    : /usr/bin/javac
Java headers gen.: 
Java archive tool: /usr/bin/jar

I do have javah in /usr/bin. But how do I "tell" this to R?

prosoitos
  • 6,679
  • 5
  • 27
  • 41
  • Can you go to usr/bin and check whether javah is present? – Absent Apr 25 '18 at 07:40
  • I have a symlink: `javah -> /usr/lib/jvm/default/bin/javah` – prosoitos Apr 25 '18 at 07:47
  • Oh! Your comment pushed me to follow the symlink (and a 2nd symlink in the path) and to find out that there is no `javah` in `/usr/lib/jvm/default/bin/`. So I guess that's why R can't find it... When I was looking for `javah` with `locate` to make sure it existed, I was getting the symlink as a result. So I thought that it was fine and failed to see that it lead nowhere. Now... I am not sure where to find `javah`... – prosoitos Apr 25 '18 at 08:06
  • (Thank you @IvoVidovic for pointing me to the right direction). – prosoitos Apr 25 '18 at 08:13
  • Now... where do I find `javah`? [This thread](https://stackoverflow.com/questions/13526701/javah-missing-after-jdk-install-linux) did not help me. And the only `javah` I seem to have on my machine is that symlink leading to a non existent file. – prosoitos Apr 25 '18 at 08:38
  • On my machine it is in the same package as javac and since you have javac you have installed a jdk, so I don't know, maybe try reinstalling your jdk? – Absent Apr 25 '18 at 08:41
  • Apparently, `javah` is missing from the arch linux openjdk 10 ([the file is not listed in the package contents](https://www.archlinux.org/packages/extra/x86_64/jdk10-openjdk/))... I guess I will try to install another openjdk. – prosoitos Apr 25 '18 at 08:48

1 Answers1

2

Thanks to @IvoVidovic's comment, I went to /usr/bin and inspected javah. It turned out that it was a symlink to a non-existent file. In fact, javah is missing from Arch Linux OpenJDK 10 (the file is not listed in the package contents).

  • Installing OpenJDK 9,
  • updating my JAVA_HOME with export JAVA_HOME=/usr/lib/jvm/java-9-openjdk,
  • setting OpenJDK 9 as my default jdk with sudo archlinux-java set java-9-openjdk,
  • and re-running sudo R CMD javareconf allowed R to find all the java files, including javah.

I now have:

Java interpreter : /usr/bin/java
Java version     : 9.0.4
Java home path   : /usr/lib/jvm/java-9-openjdk
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

and I could install rJava without any issue.

Thanks again to @IvoVidovic who sent me in the right direction with his comment.

prosoitos
  • 6,679
  • 5
  • 27
  • 41