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.


Thanks @cderv,

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



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.


I totally agree with you ! :+1:


Thanks guys - The help was very much appretiated