The steps to install rjava on a 64 bit machine is not very different from installing it on a 32 bit machine. however, here are the exact steps.
1. Install 64 bit java.
2. Install R 2.12.X
3. Start R and install the rjava package using the package installer.
4. Start eclipse. Create a project called RTest. copy the Rtest.java and RTest2.java files from the examples folder of rjava (R-2.12.2libraryrJavajriexamples)
5. Create a lib folder in the RTest project and copy the jri.jar file from R-2.12.2libraryrJavajri into it.
6. add jri.jar to the classpath of the project. ensure that the project compiles without error.
Here’s the folder structure
7. Before running the RTest.java class, the run configuration needs to be edited. open the run configuration by clicking on run->run configuration. select Rtest as project and rtest as the main class. click on environment and add the variable ‘PATH’ . the path should contain paths to the following
a. the bin directory of R (64) : R-2.12.2binx64;
b. The jri directory for rjava (64bit) : R-2.12.2libraryrJavajrix64.
This did not work for me.
I have used R-2.13.0.pkg and it installed things differently.
Envirnnment:
R_HOME = /Library/Frameworks/R.framework/Resources
PATH=/Library/Frameworks/R.framework/Resources/bin/
(In addition, the run script which comes with JRI.jar sets up R_INCLUDE_DIR, R_SHARE_DIR and R_DOC_DIR, which I all set in the run configuration).
VM argument:
-Djava.library.path=/Library/Frameworks/R.framework/Resources/library/rJava/jri/
JRI.jar is referenced in the build path, which is: /Library/Frameworks/R.framework/Resources/library/rJava/jri/JRI.jar. This appears in the -cp in the run configuration.
Also, the run configuration requires a program argument: –save, –no-save or –vanilla.
THANK YOU!!
Following the steps worked 🙂
Thank you thank you thank you! I was in .dll file hell till I found these very simple directions! Thank you. -Katie
I followed the tutorial but i am getting the following error:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: C:UsersJoão GabrielDocumentsRwin-library2.14rJavajrijri.dll: Can’t load AMD 64-bit .dll on a IA 32-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.rosuda.JRI.Rengine.(Rengine.java:19)
at tests.rtest.main(rtest.java:62)
does anyone know what could be wrong?
Thanks!
My OS is x64, but also my Java and my R, but the JRI only worked when I pointed to the i386 directory instead of pointing to x64. I still do not know why, but if someone is having the same problem I had, can go back to work doing it.
@João Gabriel
Looks like you were trying to load the 64-bit library from a 32-bit platform. This is not possible. I also had to reference the 32-bit version of R to get it to work!