Library xlsx and rJava

I am facing the following issues in RStudio running on Windows 7. I repaired Java and the jvm.dll file is also there:

library(xlsx) # necessary to write data
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
  call: .jinit()
  error: Cannot create Java virtual machine (-6)
In addition: Warning message:
package ‘xlsx’ was built under R version 3.1.3 
Error: package or namespace load failed for ‘xlsx’

Can anyone help me? I cant run the xlsx library and its crucial to my code.

Best regards

Not a solution but a hint that you may already know: It seems to be an issue with JAVA as a JVM cannot be initialized by .jinit()

FWIW, for xlsx reading and manipulations know that there is a few interesting :package:without the java dependency:

I find them to be safer and better options.

5 Likes

Thanks @cderv,

I have tried openxlsx and this seems to work. I lost 3 days on that issue,

:

1 Like

By the way, here have some dependen relation.

  • xlsx depen on xlsxjars
  • xlsxjars depen on rJava

If just library xlsx, r will library rJava at first, then library xlsxjars, then library xlsx.

For reading and writing data frames without any special formatting, readxl and writexl are great alternatives to xlsx. When I need to write summary output to Excel for colleagues, I find openxlsx to be much more intuitive and straightforward than xlsx for creating nicely formatted summary tables (e.g., borders, bold text, wrapped text, merged cells, conditional formatting, custom placement, etc.) in Excel workbooks.

6 Likes

I totally agree with you ! :+1:

Thanks guys - The help was very much appretiated

1 Like

Hello
I am unable to use xlsx
Neither are openxlsx, readxlsx and writexlsx functions available to use
Tried re-installing but it shows me this msg

library("rJava", lib.loc="~/R/win-library/3.5") Error: package or namespace load failed for ‘rJava’: .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the Registry

Pls help
Thanks

You need to install Java requirement properly on your system. The issue is with rJava that can't work because it does not have (or find) what's needed on your system.

Advice to help avoid this painful situation : look at alternative :package: mentioned in previous post. They don't have a Java dependency and are good ways to deal with excel files.

It's well known problem, it's been for many times on stackoverflow. First, i advice you to use openxlsx - it always worked good for me.
Second, start clean environment and the first thing to run will be .jinit and other java machine settlements like heap size, you run it even before libraries

A post was split to a new topic: translating xlsx.writeMultipleData("stdresids.xlsx", stdresids)" from library (xlsx) to library(writexl)