How to install ROracle on Windows 7 64-bit - r

This is a follow on to How to install ROracle package on Windows 7?
I'm getting the following error trying to build ROracle
** testing if installed package can be loaded
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'D:/Users/a101/Documents/R/win-library/3.0/ROracle/libs/x64/ROracle.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
I have RTools and 64-bit Oracle Instantclient installed
I execute the following from an Admin privieledged command line:
set OCI_LIB64=C:/Oracle/instantclient_12_1_x64
set OCI_INC=C:/Oracle/instantclient_12_1_x64/sdk/include
"C:/Program Files/R/R-3.0.0/bin/x64/R" CMD INSTALL --build ROracle_1.1-10.tar.gz
I've searched around and what I've found says this error is caused by building in mixed mode. I.e. 32-bit R with 64-bit Oracle client library or vice versa. I've been looking at this for many (many) hours and I believe I'm using all 64-bit (OS, R, Oracle client library). All the trace messages seem to indicate 64-bit everywhere. Any thoughts on what I might be missing?

To run dependency walk use Dependecy Walker, choose opening ROracle.dll in this app. I had the same issue since ROracle.dll was searching for OCI x64 (Oracle client), whereas I had x86 version of it installed on my PC.

I came across the same question, with 64bit windows and R...
Since I shifted the ROracle from 32bit to 64bit some days before. After changing the OCI_LIB64, OCI_INC and also add the 64bit instantclient dir to the env variable Path, it works fine in R and RStudio.
But I set up a task scheduler before, using Rscript.exe to run a RCode every day. That task failed since the shift with the same error:"Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'E:/app/R_lib/3.4/ROracle/libs/x64/ROracle.dll': LoadLibrary failure: %1 is not a valid Win32 application."
My final solution is to restart the computer...And the task scheduler works again....guess there should be some 32bit file stored temporarily and need to be deleted before using 64bit ROracle...

You need to add the Oracle Client 32 and 64 bits witk SDK folder directory to the Windows System enviromental variables path. Also need to install rjava package (install java 64 bits) and set JAVA_HOME in R sys.setenv().
install.packages("rJava") #Install Java 64 bits
library(rJava) #Not Errors
Sys.setenv("OCI_LIB64"="C:/instantclient_12_2_64bits")
Sys.setenv("OCI_LIB32" = "C:/instantclient_12_2_64bits")
Sys.setenv("ORACLE_HOME" = "C:/instantclient_12_2_64bits")
Sys.setenv(JAVA_HOME='C:/Program Files/Java/jre1.8.0_241')
install.packages(paste0(path,"/ROracle_1.3-1.tar.gz"), repos = NULL, type = "source")
library(ROracle)
The last message in the install process should be DONE!
In the Windows System enviromental path:
C:\instantclient_12_2_64bits;
C:\instantclient_12_2_64bits\sdk;
C:\instantclient_12_2_32bits;
C:\instantclient_12_2_32bits\sdk;
hope this works!

Related

Matching 64 bits versions but error loading rJava

I have set the JAVA_HOME to JAVA_HOME="C:\Program Files\Java\jre1.8.0_251".
I have installed a 64 bits version of Java which is matching with my 64 bits R (version 4.0.2) and Windows 10 Home.
Error remains in loading rJava as below:
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:/my_R_library/rJava/libs/x64/rJava.dll':
I tried to reinstalled JAVA and R, rJava cannot be loaded.
I tried the function find.java(), it runs properly
Is there any suggestion to deal with the problem?
My problem finally solved. Since my Windows is a Chinese version, it cannot recognise any Chinese characters in the paths if I installed an English version. What I have done is just installing a Chinese version R, no need to set the JAVA_HOME at all. I hope this can hope the potential use of R with their own langauge based Windows.
Once Java is installed on a Windows based PC, one must ensure it is configured in the operating system in a way that R can access it. First, check the Java Control Panel. In the windows 10 search bar, search for Configure Java, and then press from the list of choices for the Java Control Panel.
From the Control Panel main window, select the Java tab,
and then press the button.
At this point you should see at least one row of information that illustrates the version and location where you have Java installed.
If your version of Java isn't listed, you can use the > or buttons to find or add the version that had been installed but is not listed.
Exit the Java Control Panel, open a command window (type cmd in Windows search bar), and type
java -version
This should display the version of Java that is visible to Windows, as illustrated below.
Next, we need to confirm that Java is accessible within RStudio. Open RStudio and use the system() function to check the version of Java.
system("java -version")
We should receive the same result as we did with the Windows command line version of java -version.
> system("java -version")
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
[1] 0
At this point, one should be able to install rJava. However, if Java isn't accessible, we'll need to use the Sys.setenv() function to set the path for Java home.
# set JAVA_HOME to directory listed in Configure Java app, such as
# C:\Program Files\Java\jre1.8.0_231
Sys.setenv(JAVA_HOME="C:/Program Files/Java/jre1.8.0_231")
...and now we should be able to install rJava.
install.packages("rJava")
> install.packages("rJava")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rJava_0.9-12.zip'
Content type 'application/zip' length 1214816 bytes (1.2 MB)
downloaded 1.2 MB
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\leona\AppData\Local\Temp\RtmpWGyEQp\downloaded_packages
>

error installing xlsx package with object not loaded [duplicate]

While loading rJava package, I receive this error:
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/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
In addition: Warning message:
package ‘rJava’ was built under R version 3.2.3
Error: package or namespace load failed for ‘rJava’
I referred various posts on StackOverflow and tried to make changes accordingly, but nothing worked. These are the various steps I followed to resolve the issue:
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
This didn't work.
Then I tried this:
options(java.home="C:\\Program Files\\Java\\jre1.8.0_91\\")
library(rJava)
This didn't work either.
My jvm.dll is at this location in my Windows 7 64 bit OS - C:\Program Files (x86)\Java\jre1.8.0_91\bin\client
I also added C:\Program Files (x86)\Java\jre1.8.0_91\bin\client to my PATH variable in my Environment variables and restarted RStudio and tried to install and load rJava again. That also didn't work.
I would really appreciate if someone could please help me resolve this issue.
Thanks guys!
This worked for me -
This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.
Note that it is necessary to ‘manually download and install’ the 64 bit version of JAVA. By default, the download page gives a 32 bit version .
You can pick the exact version of Java you wish to install from this link. If you might (for some reason) work on both versions of R, you can install both version of Java (Installing the “Java Runtime Environment” is probably good enough for your needs).
(Source: Uwe Ligges)
Other possible solutions is trying to re-install rJava.
If that doesn’t work, you could also manually set the directory of your Java location by setting it before loading the library:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre7') # for 32-bit version
library(rJava)
Refer this link - http://www.r-bloggers.com/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/
I encountered the same problem. Be sure to check the file path for Java. To solve the error I needed to download 64bit Java version. However the following code in R did not work as the folder was incorrect for the latest version for Java:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Instead I changed the name to:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_144')
Hope that helps
I have noticed in different fresh installations of R, RStudio and rJava in WIndows, that what fixes the error is:
Uninstall R
Reinstall R but only selecting one architecture. Example, x64, or x86, but not both. That tends to confuse R or RStudio when they are compiling.
In my case, I fixed the message
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/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Following steps 1 and 2 above.
I tried what the other have said to not avail. For me the solution was to eliminate the old folders and shortcuts of R version 32 bit on my computer that remained there even after uninstalling.
This happened to me when Java was updated to a 32-bit, but R required a 64-bit version.
The solution:
Simply download the 64-bit version of Java
install it.
Restart RStudio
Everything should work
Where to download 64-bit java:
I guess your OS architecture and R architecture are not matching. If they are matching, the following might be the problem
It worked for me after i added the R library path to the environment variables list on my windows 7.
So,
Add 'C:/Users/Rohan-PC/Documents/R/win-library/3.1' this path to the Path variables list under System variables list(not to be confused with the PATH variable under User variables). Restart R and try loading the library. It works!!!!!
If you have both 64-bit R and 32-bit R versions installed, try from each one.
For me it worked on R 64bits but not R 32bits.
But of course that depends on your java version (64-bit Java vs 32-bit Java).

32-bit and 64-bit error in building R package which calls Fortran

I'm trying to build an R package which calls Fortran code in Windows system. R BUILD works well but I got some error in R CHECK or R INSTALL.
To compile the Fortran code to get a dll file in Windows system, I have to specify x64 (64 bit) or i386 (32-bit). But when I used dll file compiled by x64 in R CHECK, I will get the error:
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.3.1/bin/catch.Rcheck/catch/libs/i386/tensor.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Similarly, if I used the dll file compiled by i386, I will get error in 64-bit installation.
I was wondering is there any way that I can specify using dll from x64 to build a package works for 64 bit machine and dll from i386 to build one for 32 bit machine. Thanks!
It's been a while, but just in case people have the same issue. It's a designed issue and the 32-bit and 64-bit compiled files need to be built separately. Solution is that to build 64 bit version, i386 needs to be moved out of the folder.

R - Error : .onLoad failed in loadNamespace() for 'rJava'

While loading rJava package, I receive this error:
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/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
In addition: Warning message:
package ‘rJava’ was built under R version 3.2.3
Error: package or namespace load failed for ‘rJava’
I referred various posts on StackOverflow and tried to make changes accordingly, but nothing worked. These are the various steps I followed to resolve the issue:
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
This didn't work.
Then I tried this:
options(java.home="C:\\Program Files\\Java\\jre1.8.0_91\\")
library(rJava)
This didn't work either.
My jvm.dll is at this location in my Windows 7 64 bit OS - C:\Program Files (x86)\Java\jre1.8.0_91\bin\client
I also added C:\Program Files (x86)\Java\jre1.8.0_91\bin\client to my PATH variable in my Environment variables and restarted RStudio and tried to install and load rJava again. That also didn't work.
I would really appreciate if someone could please help me resolve this issue.
Thanks guys!
This worked for me -
This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.
Note that it is necessary to ‘manually download and install’ the 64 bit version of JAVA. By default, the download page gives a 32 bit version .
You can pick the exact version of Java you wish to install from this link. If you might (for some reason) work on both versions of R, you can install both version of Java (Installing the “Java Runtime Environment” is probably good enough for your needs).
(Source: Uwe Ligges)
Other possible solutions is trying to re-install rJava.
If that doesn’t work, you could also manually set the directory of your Java location by setting it before loading the library:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre7') # for 32-bit version
library(rJava)
Refer this link - http://www.r-bloggers.com/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/
I encountered the same problem. Be sure to check the file path for Java. To solve the error I needed to download 64bit Java version. However the following code in R did not work as the folder was incorrect for the latest version for Java:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Instead I changed the name to:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_144')
Hope that helps
I have noticed in different fresh installations of R, RStudio and rJava in WIndows, that what fixes the error is:
Uninstall R
Reinstall R but only selecting one architecture. Example, x64, or x86, but not both. That tends to confuse R or RStudio when they are compiling.
In my case, I fixed the message
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/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Following steps 1 and 2 above.
I tried what the other have said to not avail. For me the solution was to eliminate the old folders and shortcuts of R version 32 bit on my computer that remained there even after uninstalling.
This happened to me when Java was updated to a 32-bit, but R required a 64-bit version.
The solution:
Simply download the 64-bit version of Java
install it.
Restart RStudio
Everything should work
Where to download 64-bit java:
I guess your OS architecture and R architecture are not matching. If they are matching, the following might be the problem
It worked for me after i added the R library path to the environment variables list on my windows 7.
So,
Add 'C:/Users/Rohan-PC/Documents/R/win-library/3.1' this path to the Path variables list under System variables list(not to be confused with the PATH variable under User variables). Restart R and try loading the library. It works!!!!!
If you have both 64-bit R and 32-bit R versions installed, try from each one.
For me it worked on R 64bits but not R 32bits.
But of course that depends on your java version (64-bit Java vs 32-bit Java).

How can I install rJava for use with 64bit R on a 64 bit Windows computer?

I installed iplots and rjava packages. When I do this library(iplots), I get the following error. I do have JDK installed on my pc.
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package ‘rJava’ could not be loaded
The error is telling you that there is no entry in your Registry that tells R where Java is located on your machine. Either your registry is corrupt, but more likely you haven't installed Java. You can install either the Java Runtime Environment or the Java Development Kit.
(You can download Java here.)
If you installed Java, try reinstalling it. This should put the entries back in your Registry.
If that doesn't work, you can start looking at exactly where R is looking for your Registry entries. The function that rJava uses to find Java is in the rJava:::.onLoad function. Within that function there is a subfunction called find.java. I copy the contents here:
find.java <- function() {
for (root in c("HLM", "HCU")) for (key in c("Software\\JavaSoft\\Java Runtime Environment",
"Software\\JavaSoft\\Java Development Kit")) {
hive <- try(utils::readRegistry(key, root, 2),
silent = TRUE)
if (!inherits(hive, "try-error"))
return(hive)
}
hive
}
Copy and paste this into your R window, and then run it find.java(). rJava is looking for an entry for JavaHome. If that isn't listed, then it is missing from your registry.
You could also manually set the directory of your Java location by setting it before loading the library:
Sys.setenv(JAVA_HOME='C:\\Your\\Java\\Directory')
library(rJava)
If like me you do not have admin rights to install 64-bit Java, just open 32-bit R and it should work ok on your 64 bit PC as part of the problem seems to be the rJava library function calls embedded Java functions/routines, which may only have being designed for 32-bit interface with Excel/Windows and possibly too large a task at the time to change everything.
Answer in link resolved my issue.
Before resolution, I tried by adding JAVA_HOME to windows environments. It resolved this error but created another issue. The solution in above link resolves this issue without creating additional issues.
Any Linux users here, run command:
sudo R CMD javareconf
That typically needs to be run after an update of the system Java installation,
as suggested here

Resources