error: JAVA_HOME cannot be determined from the Registry

[This article was first published on Methods – finnstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

error: JAVA_HOME cannot be determined from the Registry, This error notice happens most frequently when we try to load the xlsx package.

Approach 1: error: JAVA_HOME cannot be determined from the Registry

The error message “JAVA HOME cannot be identified from the Registry” will be replicated in this example.

aggregate Function in R- A powerful tool for data frames »

install.packages("xlsx") 
library("xlsx")
# Loading required package: xlsx
# Loading required package: xlsxjars
# Loading required package: rJava
# Error : .onLoad failed in loadNamespace() for 'rJava', details:
#   call: fun(libname, pkgname)
#   error: JAVA_HOME cannot be determined from the Registry
# Failed with error:  'package 'rJava' could not be loaded'

After installing and loading the xlsx package, the error “JAVA HOME cannot be found from the Registry” was returned to the R interface.

What are the differences between Association and Correlation? »

This issue, however, is caused by the rJava package, not the xlsx package. When we install the xlsx package, R also wants to install the rJava package.

When we try to install the rJava package, we get the error message “JAVA HOME cannot be obtained from the Registry.”

This is frequently due to the fact that you are running a 64-bit version of R but not a 64-bit version of Java. It’s possible that you installed a 32-bit version of Java or that you didn’t install Java at all.

It’s worth noting that the Java download page defaults to the 32-bit version. As a result, the 64-bit version must be installed manually.

SharePoint R integration and analysis » Automation »

Approach 2: Fixing the Error: JAVA_HOME cannot be determined from the Registry

Here we are showing how to fix difficulties caused by rJava when trying to load an R package.

Download and install the 64-bit version of Java: Java 64-bit for Windows is available for download.

After installing the 64-bit version of Java, we must reinstall and load the rJava package (or, in our case, the xlsx package):

install.packages("xlsx")         
library("xlsx")                  

This time it went off without a hitch!

Naive Bayes Classification in R » Prediction Model »

The post error: JAVA_HOME cannot be determined from the Registry appeared first on finnstats.

To leave a comment for the author, please follow the link and comment on their blog: Methods – finnstats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)