0

EDIT:1 I have already seen Using the rJava package on Win7 64 bit with R

I have Windows 7 64-bit Machine with R 3.1.0, Java 7u67 64-bit installed. (NOTE: I am not allowed to update R)

JAVA_HOME is set to C:\Program Files\Java\jre7

and PATH includes

C:\Program Files\Java\jre7\bin and C:\Program Files\Java\jre7\server (the last entry is for jvm.dll file)

From R prompt I can see that RStudio is using 64-bit R

R version 3.1.0 (2014-04-10) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

> .Machine$sizeof.pointer
[1] 8    

I can load rJava library just fine

> options(java.home="C:\\Program Files\\Java\\jre7\\")
> library(rJava)

Warning message:
package ‘rJava’ was built under R version 3.1.1 

But when I try to install install bigR package on my machine and I am getting following error message

> install.packages("C:/local/bigr-1.0.tar.gz", repos = NULL, type = "source")
Installing package into ‘C:/Users/alex/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
* installing *source* package 'bigr' ...
** R
** inst
** preparing package for lazy loading
Warning: package 'rJava' was built under R version 3.1.1
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.0/library/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  The specified module could not be found.

Error : package 'rJava' could not be loaded
ERROR: lazy loading failed for package 'bigr'
* removing 'C:/Users/alex/Documents/R/win-library/3.1/bigr'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" CMD INSTALL -l "C:\Users\alex\Documents\R\win-library\3.1" "C:/local/bigr-1.0.tar.gz"' had status 1
Warning in install.packages :
  installation of package ‘C:/local/bigr-1.0.tar.gz’ had non-zero exit status

Any help to solve this problem will be much appreciated..

Community
  • 1
  • 1
Khurram Majeed
  • 2,291
  • 8
  • 37
  • 59
  • 1
    As a first step I would update R. – Roland Aug 18 '14 at 09:47
  • possible duplicate: http://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r – EDi Aug 18 '14 at 09:49
  • @EDi I have already seen that post that's how I found out about setting the JAVA_HOME from R. I think my issue is with bigR package not rJava – Khurram Majeed Aug 18 '14 at 10:02
  • What does "not allowed to update R" mean? You don't need admin rights to install R. Is there a company policy forbidding this? Anyway, your output shows that rJava package seems to be installed into `C:/Users/alex/...`, but that during the install process it is looked for in `C:/Program Files/R/...`. – Roland Aug 18 '14 at 12:18

2 Answers2

2

I had the same problem with running library(rJava) on R 3.1.1 / RStudio 0.98.1073 on 64-bit Windows 8.1 and 64-bit Windows 7.

Temporary solution is to set JAVA_HOME environment variable in R/RStudio console at start of each session:

In RStudio console on Windows 7 64-bit with latest Java Runtime installed:

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7\\')

In RStudio console on Windows 8.1 64-bit with latest Java SDK installed:

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

Permanent solution requires adding new Window's Envionment Variable to the appropriate java runtime folder:

Add variable JAVA_HOME equal to C:\Program Files\Java\jre7\

Add variable JAVA_HOME equal to C:\Program Files\Java\jdk1.8.0_20\jre\

I ran into this problem with xlsx and XLConnect packages --- I seem to have missed the notice that these require the Java Runtime to be installed and JAVA_HOME environment variable set for them to work properly.

R Newbie --- Charles.

PS Also note that when setting the environment variable JAVA_HOME in Windows, the path to jre or jre7 is NOT enclosed in single or double quotes and does not require \ be replaced with \\ as is done when setting these in the R/RStudio console window.

1

I managed to get the problem sorted by doing the following steps:

  1. Un-installed all java versions
  2. Removed entries pointing to java in system level environment variables
  3. Re-installed java (jre-7u67-windows-x64) from Oracle website

After that everything worked fine.

Khurram Majeed
  • 2,291
  • 8
  • 37
  • 59