SoFunction
Updated on 2025-03-01

Problems and solutions encountered in installation based on R language xlsx

1. Installation of Java environment. If Java is installed with 64-bit R software, it must be 64-bit. If you use 32-bit, an error will be reported, and the version must be corresponding.

2. If the installation order is ("rJava")

(“xlsxjars”)
(“xlsx”)

3. If the installation was not in the order of installation 2 before, although the rJava or xlsxjars packages were downloaded, xlsxjars cannot be installed. At this time, you can choose to find rJava or xlsxjars in the library under the R installation directory to delete it and install it again in the R console.

4. If the rJava installation is already open and cannot be installed, you can use (.packages()) to view the currently loaded installation package. If you find that rJava has been loaded, you can use detach ("package:rJava") to uninstall the installation package, and then execute install.

Supplement: Installing the xlsx package in R language has hits the pit

Cause of the problem:

Error problem:

Can't install directly ("xlsx")

Load the required program package: rJava

Error: .onLoad failed when calculating 'rJava' in loadNamespace(), details:

Call: fun(libname, pkgname)

Error: JAVA_HOME cannot be determined from the Registry

Error: Cannot load the program edit package 'rJava'

reason:

It may be that the computer does not have Java installed

Solution

1. Install java

Install the latest version of java. If you are using R, please download 64-bit java.

Download address: /en/download/

Download windows offline(64)

To install it in C:\Program Files\Java** [for 64-bit version library(rJava)]; be careful not to install it as C:\Program Files(x86). [(x86) for 32-bit version library(rJava)]**:

Loading the environment in R, that is, a line of code, the path needs to be changed according to your java version.

(JAVA_HOME=‘C:\Program Files\Java\jre1.8.0_45\')

Or directly add java to environment variables: C:\Program Files\Java\jre1.8.0_45\

2. Install the package

The installation order should be

(“rJava”)
(“xlsxjars”)
(“xlsx”)

If the installation was not in the order of installation 2 before, although the rJava or xlsxjars packages were downloaded, xlsxjars cannot be installed. At this time, you can choose to find rJava or xlsxjars in the library under the R installation directory and delete it, and install it again in the R console.

If the rJava installation is already open and cannot be installed, you can use (.packages()) to view the currently loaded installation package. If you find that rJava has been loaded, you can use detach ("package:rJava") to uninstall the installation package, and then execute install.

The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.