Problem with rJava on Rstudio in Anaconda on Cent OS7

Hello,
I have rstudio in jupyter (both R and Jupyter are from anaconda). Unfortunatelly I have problem with rJava package. When I try to load the package I have following error:

Loading required package: rJava
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for ‘rJava’, details:
call: dyn.load(file, DLLpath = DLLpath, …)
error: nie można załadować współdzielonego obiektu ‘/opt/anaconda3/envs/R_kernel/lib/R/library/rJava/libs/rJava.so’:
libjvm.so: nie można otworzyć pliku obiektu dzielonego: Nie ma takiego pliku ani katalogu

I try
sudo R CMD javareconf JAVA_HOME=/opt/anaconda3/envs/R_kernel/lib

but still it doesn’t help.
I check also

Sys.getenv(“JAVA_HOME”) which give me ‘/opt/anaconda3/envs/R_kernel’
Sys.getenv(“LD_LIBRARY_PATH”) or Sys.getenv(“LIBRARY_PATH”) give me empty result (only ").

What can I do also to have rJava working properly ?

1 Like

Do you have a JAVA JDK installed? This is required in order for the rJava package to work.
I suggest looking at this discussion for further information:

1 Like

Dear sweller,
Yes I have installed JAVA JDK:

My version:
openjdk version “11.0.15” 2022-04-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode, sharing)

I also read “rJava fails to load” nad try solutions from there, but unfortunatelly, still it isn’t working.

Can you run the command:
‘R CMD javareconf’

and paste the output below?

Thanks.