3

I have to load an Excel file .xlsx on R, but:

library(xlsx)

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/danil/Documents/R/win-library/3.4/rJava/libs/x64/rJava.dll': LoadLibrary failure: Impossibile trovare il modulo specificato. Error: package ‘rJava’ could not be loaded

So, I tried to install Java, Java SE-Development Kit 10 and Java Runtime Environment 10, 64 bit for both. But, also in this case:

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/danil/Documents/R/win-library/3.4/rJava/libs/x64/rJava.dll': LoadLibrary failure: Impossibile trovare il modulo specificato.

What can I do?

9
  • Hi @francesco... welcome to SO. I've edited your title to be a bit more informative as a question. Commented Apr 7, 2018 at 19:07
  • No problem, i hope that it will also help anybody else. Commented Apr 7, 2018 at 19:13
  • How did you install xlsx package? Or have a look here stackoverflow.com/q/37735108/5784831 Commented Apr 7, 2018 at 19:25
  • I wasnt'able to install xlsx package... It says "Error: package or namespace load failed for ‘rJava’". I don't know what to do, i'm a newbie of R. Commented Apr 7, 2018 at 20:26
  • What is your OS? Usually, when I get these errors, I look all over the error messages, such often there will be some libraries/packages suggested for installing for each operating system. Commented Apr 8, 2018 at 3:23

2 Answers 2

2

This was happening to me as well (also Windows 10), and the problem with mine was that the environment variable was not set properly. In my case, I had to do

Sys.setenv('JAVA_HOME' = 'C:/Program Files (x86)/Java/jre1.8.0_161/')

Just change the folder name to where Java lives in your computer, and let me know if this doesn't work out.

Sign up to request clarification or add additional context in comments.

1 Comment

Do you happen to know why do we need to setenv() for JAVA_HOME in R, when I had already set JAVA_HOME in system variables? Using Windows 10
0

In Ubuntu 16.04 I did the following trick in RStudio:

Sys.setenv('JAVA_HOME' = '/usr/lib/jvm/java-8-oracle/jre')

Surprisingly, but

Sys.setenv('JAVA_HOME' = '/usr/lib/jvm/java-8-oracle/')

didn't work for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.