Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

Unable to load rJava on R

I wish to load rJava in R x64 3.1.2. OS- Windows 8.1 64 bit

Though installation seems to work fine:

  > install.packages("rJava")
    Installing package into ‘C:/Users/sony/Documents/R/win-library/3.1’
    (as ‘lib’ is unspecified)
    --- Please select a CRAN mirror for use in this session ---
    trying URL 'http://cran.utstat.utoronto.ca/bin/windows/contrib/3.1/rJava_0.9-6.zip'
    Content type 'application/zip' length 758898 bytes (741 Kb)
    opened URL
    downloaded 741 Kb

package ‘rJava’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
        C:UserssonyAppDataLocalTempRtmpamYUH7downloaded_packages

I get an error while loading the package:

library(rJava)
Error in get(Info[i, 1], envir = env) : 
  lazy-load database 'C:/Users/sony/Documents/R/win-library/3.1/rJava/R/rJava.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
Error: package or namespace load failed for ‘rJava’

I know that I am working on R-64 bit and at same time the environment variable Path is set to:

C:Program FilesJavajdk1.7.0_51in;C:Program FilesJavajre7inserver;

also, so the Java version is 64 bit too. I don't understand the reason behind the error.

On manually setting through R:

options(java.home="C:\Program Files\Java\jdk1.7.0_51\bin")
library(rJava)

I get this error:

enter image description here

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

Error: package or namespace load failed for ‘rJava’

Any advice? The error seems to have cropped up after I uninstalled some old version of Java.

OTHERS: Also just to add, I do not set JAVA_HOME as a environment variable.

Uninstalling and Reinstalling R also doesn't seem to fix the problem.

Removing older java versions is too of no help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...