Problem loading rJava

I am trying to load the rJava library (really i want to use xlsx but rJava is a dependency)
I am getting a pop up window

image

and this error message

> library(rJava)
Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Users/rdonatello/Documents/R/R-4.0.0/library/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  The specified procedure could not be found.
In addition: Warning message:
package ‘rJava’ was built under R version 4.0.2

My JAVA_HOME and PATH are set correctly

JAVA_HOME C:\Program Files\AdoptOpenJDK\jre-8.0.252.09-hotspot\

I'm using -

  • Windows 10x64
  • R 4.0.0

Do you need to write xlsx? If you're just reading I found tidyxl was good. rJava is a pain in the butt.

Here is an Excel analyser I wrote which uses it.

https://github.com/woodwards/excel2r

Can you just use csv files? Excel can read those natively.

Personally I think having to manipulate Excel files using R sounds like hell :face_vomiting:

1 Like

i see this has a writeDataTable function, which is the functionality that brought me to the xlsx package. I'll give it a go. thanks @joels

I think you've run into this issue, where some packages built on R 4.0.1 or later don't work on R 4.0.0. rJava seems to be one of the affected packages. Could you try upgrading to R 4.0.1 or 4.0.2, then try loading rJava again?

Edit: looks like this will be fixed in the next version of rJava: https://github.com/s-u/rJava/blob/ec6e26832e142ddb6149d414f6b4e0bcffecdec9/NEWS#L11-L12

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

Yep, i want to write to specific cells in excel (i.e. not starting at A1) and so far this package is the only one that i've seen that can do that.

No.... i cannot use CSV. The file i'm writing to has to maintain a particular formatting.
If you don't know the answer to my question about rJava, that's fine but please stop trying to tell me to do something different entirely with respect to my file format.

1 Like

Well why didn't you say that at the start? All you said is "I want to use xlsx".

1 Like

I suggest using the openxlsx package for writing formatted Excel files. It doesn't have a java dependency and I've found the formatting syntax easier to use than xlsx. It has tutorial vignettes for basic usage and formatting output.

1 Like