Unable to load rJava on R

给你一囗甜甜゛ 提交于 2019-11-26 17:42:34
qjgods

Use:

Sys.setenv(JAVA_HOME='...path to JRE...')

e.g.

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk1.7.0_51\\jre')

Your environment variable is wrong.

manoj

I got a similar error:

> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/program files/R/R-3.1.2/library/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  The specified module could not be found.

My JAVA_HOME was pointing to JDK, rather than JRE.

> Sys.getenv("JAVA_HOME")
[1] "c:\\java\\jdk1.7.0_55"
> Sys.setenv(JAVA_HOME="c:\\java\\jdk1.7.0_55\\jre")

I could now load rJava and xlsx in R.

Sunny

I've met a similar problem and spent an entire day to get it fixed. Although my computer, windows7, and Rstudio are 64 bit, but my Java is 32 bit(!) Once I realized that, I download a 64 bit Java. I have to manually download, the automatic download will lead to the 32 bit version because my chrome browser is 32 bit. 64 bit Java will be automatically installed in

C:\Program Files\Java, however, 32 bit Java will be automatically installed in C:\Program Files (x86) \Java.

This is an important indicator telling me my Java is 64 bit or 32 bit.

After installing the 64 bit Java, everything works perfect!

I get this error every time Java sneaks an update onto my PC. When I go:

Sys.getenv("Path")

I find something in the output which looks like

C:\\Program Files \\Java\\jre1.8.0_112\\bin\\server\\

where the last few digits of the jre subfolder are outdated.

To fix this everywhere, you might want to edit the Windows environment variable. Do this by going WINDOWS + X key, selecting Command Prompt (Admin) from the menu, and typing

rundll32.exe sysdm.cpl,EditEnvironmentVariables

in the command box. This will call up this dialog box with edit rights for the PATH variable (and other system variables):

The Windows interface for editing long environment variables is a bit unwieldy, so after I click Edit... I like to copy-paste the resulting mess of paths to Notepad.exe, do the work there, and copy-paste back.

Faced similar error message.

Tried a few steps listed here.

  1. Set Env. Variable, JAVA_HOME. => Didn't work.
  2. Tried to install rJava +> Didn't work Steps 3,4,5 worked..
  3. Updated my Java 64 bit version 8.xx (latest available)
  4. install.packages(rJava) ==> Success
  5. install.packages(RWeka) ==> Success

Had the same issue:

I was running 64-bit R you can check which version by closing and re-openning RStudio. It should be at the top.

I had 32-bit java installed i.e. Java folder was within C:\Program Files (x86).

I simply went on to Java.com and downloaded the 64-bit Java and added it's location at the end of the PATH in System variables and I can load rJava now. (The installation asked me to get rid of the old version which I did)

It is probably the issue with the setting with the JAVA_HOME pointer. In case you do not have JDK but JRE, here is you might have to do: Sys.setenv(JAVA_HOME='C:\Program Files\Java\jre1.8.0_161')

Remember to change the numbers after "jre" based on what you have on your computer. Here is a link that explains the difference between JDK and JRE.

Try downloading the RStudio daily build: http://dailies.rstudio.com

It worked for me on the second try after I tried everything else (updated R, Rstudio, Java, reinstalled rJava a million times, and followed all the stackoverflow advice).

The tip came from the RStudio support forums:

RStudio is indeed failing to read some of the start-up information normally provided by R here...

We have a potential fix for this in the latest daily builds of RStudio -- if you're willing, you can try downloading and testing from http://dailies.rstudio.com

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!