thequadge
thequadge

Reputation: 79

R - XLConnectJars install fails because rJava is not installed correctly

I am trying to install XLConnectJars to R and I keep getting the following error despite having Java DK and rJava installed?

Error: Package as namespace load failed for 'XLConnectJars'
.onLoad failed om LoadNamespace() for 'rJava', details:
call: library.dynam("rJava",pkgname,libname)
error: DLL 'rJava' not found: maybe not installed for this architecture?

Any help greatly appreciated!

Upvotes: 0

Views: 2532

Answers (1)

Len Greski
Len Greski

Reputation: 10875

XLConnectJars is a support package used by XLConnect, a platform-independent interface to Microsoft Excel. In order for XLConnectJars to install correctly, one must also install the rJava package.

The error noted in the OP indicates that rJava did not install correctly.

error: DLL 'rJava' not found: maybe not installed for this architecture?

Many people encounter problems installing rJava because it cannot access the Java Runtime from the operating system. Solutions to the "unable to access Java runtime" problem vary by operating system.

Windows

People often have 32-bit Java installed and then use 64-bit R. The 64-bit version of R requires the 64-bit version of Java.

Solution: Install the 64-bit version of the Java Runtime for Windows from the Java Download web page.

MacOS

Details to configure rJava on MacOS are covered in another SO answer I posted, Unable to load rJava in RStudio, which I am reposting here for convenience.

There is a very specific sequence of steps that must be taken to get rJava to work on a Macbook, as documented in rJava Issues #86.

  1. Download and install Java from Oracle
  2. Uninstall any previously installed version of rJava
  3. Add JAVA_HOME to your .bashrc
  4. Close & restart terminal, R and RStudio sessions so they pick up the updated JAVA_HOME
  5. Use install.packages() to install rJava

See the URL link above for additional details on each step.

Ubuntu Linux

Use the Advanced Packaging Tool to install Java, then reconfigure Java support in R.

  sudo apt-get install openjdk-8-jdk # openjdk-9-jdk has some installation issues
  sudo R CMD javareconf

Once these steps are completed, install the XLConnectJars package with install.packages("XLConnectJars").

NOTE: some of this content is adapted from an article I previously posted on my Github site, Common Problems with Java and the xlsx Package.

Upvotes: 1

Related Questions