R language loading xlsx error error: JAVA_HOME cannot be determined from the Registry

OnLoad failed for ‘XLSX’ :
loadNamespace() calculate ‘rJava’; onLoad failed,
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
This is because my computer is not installed the JAVA environment, right now I need to download and install the JDK, website download address: https://www.oracle.com/java/technologies/javase-downloads.html, the website need to register account and download speed is slow, there are baidu network location 64 downloads: link: https://pan.baidu.com/s/1WQvo3UyVPtBypGcCLLCLzQ extracted code: wg5o
After downloading, which contains the method to install the JDK, introduce a public number, commonly used in all kinds of software download source and installation methods ~
After installing the JDK, first find the location of R installation package. Generally in the library document under R-4.0.2, delete the packages that were not installed successfully before. Here, I will delete RJava, Xlsxjars, and XLSX

After you delete it, go back to the Rstudio window and install it in the order rJava, XlsXJars, and XLSX. There are two ways to install the Package of R, either way
Method 1: Run the script
Install. Packages (” rJava “)
install. Packages (” xlsxjars “)
install. Packages (” XLSX “)
Method 2:


After installing library(XLSX), there will be no errors!!

Read More: