R: Cannot Install Rjava; What Is R-Api-3.4

R: Cannot install rJava; what is r-api-3.4?

The API versions are provided by r-base-core. The reason is that binary packages (sometimes) depend on the R version, for which they have been build. This way you can only install packages that fit together.

In your case you have packages from the main Ubuntu repository (r-base-core 3.4.x providing r-api-3.4 and r-cran-rjava requiring r-api-3.4) and from a custom PPA (r-base-core 3.5.y providing r-api-3.5). One option would be to only use the version from Ubuntu, i.e. R 3.4. Another solution is to add an additional PPA:

sudo add-apt-repository ppa:marutter/c2d4u3.5
sudo apt-get update

After that a version of r-cran-rjava requiring r-api-3.5 should be available.
See also http://rubuntu.netlify.com/post/2018-05-25-announcing-c2d4u3-5/ and http://rubuntu.netlify.com/post/2018-06-11-r-3.5-on-debian-and-ubuntu-update/.

Finally, you always have the possibility to install the R packages directly from CRAN. That is currently the only possibility when you are using the CRAN supplied R backports on Debian.

R: rJava package install failing

Turns out my problem was an issue with my JAVA_HOME environment variable. Yes, shocking I know. My initial setting for PATH and JAVA_HOME looked like this:

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

And I added /jre so it now looks like this:

export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
export PATH=$PATH:$JAVA_HOME/bin

Everything in Java seemed to work fine without the /jre but rJava would not. Odd.

Unable to load rJava on R

Use:

Sys.setenv(JAVA_HOME='...path to JRE...')

e.g.

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk1.7.0_51\\jre')

Your environment variable is wrong.

Can't install rJava in R/RStudio

Your JAVA_HOME is pointing to JRE folder. You need to set it to JDK folder.

You can use /usr/libexec/java_home -v <version you want> to get the path you need for JAVA_HOME. For instance, to get the path to the 1.7 JDK you can run /usr/libexec/java_home -v 1.7 and it will return the path to the JDK. In your .profile or .bash_profile just add export JAVA_HOME=/usr/libexec/java_home -v <version> and you should be good.

Do javac -version if you want to check JDK installation.

How can I install rJava for use with 64bit R on a 64 bit Windows computer?

The error is telling you that there is no entry in your Registry that tells R where Java is located on your machine. Either your registry is corrupt, but more likely you haven't installed Java. You can install either the Java Runtime Environment or the Java Development Kit.

(You can download Java here.)

If you installed Java, try reinstalling it. This should put the entries back in your Registry.

If that doesn't work, you can start looking at exactly where R is looking for your Registry entries. The function that rJava uses to find Java is in the rJava:::.onLoad function. Within that function there is a subfunction called find.java. I copy the contents here:

    find.java <- function() {
for (root in c("HLM", "HCU")) for (key in c("Software\\JavaSoft\\Java Runtime Environment",
"Software\\JavaSoft\\Java Development Kit")) {
hive <- try(utils::readRegistry(key, root, 2),
silent = TRUE)
if (!inherits(hive, "try-error"))
return(hive)
}
hive
}

Copy and paste this into your R window, and then run it find.java(). rJava is looking for an entry for JavaHome. If that isn't listed, then it is missing from your registry.

You could also manually set the directory of your Java location by setting it before loading the library:

Sys.setenv(JAVA_HOME='C:\\Your\\Java\\Directory')
library(rJava)


Related Topics



Leave a reply



Submit