Setting up R-Java in Netbeans is pretty straight forward. For those who need a walkthough here are the steps.
- Download and install R (for this example version 2.12.2). install rJava package.
- Download and install Netbeans.
- In Netbeans Create a new java project. we will call it RJava.
- From the [R_HOME]>/library/rJava/jri/examples folder, copy the file rtest.java into the project.
- Create a library in NetBeans and add the following jars to the library. - JRI.jar, JRIEngine.jar, REngine.jar. These files are present in [R_HOME]/library/rJava/jri/. Here's how the project looks like
- Minimize Netbeans. Add R_HOME variable (right click my computer-> properties-> Advanced ->Environment variables) R_HOME should point to the location where R is installed.
- edit the PATH variable and append the following (i) [R_HOME]\library\rJava\jri and (ii) [R_HOME]\bin




3 comments:
May i ask some question here. I am a beginner of R and Java. The JRI actually show that R and Java are able to interface each other, that mean R and Java is compatible? If i write some R code and i hope to run in Java, how it work? can u some me an simple example? like i write a R code which read the first line data of a file and then sum it and save in other file. I able to do this from R but how can i run the R code and show the result it java? how it interfacing?
I am getting the following error. Please help
------------------------------------
Creating Rengine (with arguments)
Rengine created, waiting for R
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6c733cd8, pid=1488, tid=3220
#
# JRE version: 7.0_01-b08
# Java VM: Java HotSpot(TM) Client VM (21.1-b02 mixed mode windows-x86 )
# Problematic frame:
# C [R.dll+0x33cd8]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Program Files\R\R-2.15.1\library\rJava\jri\hs_err_pid1488.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
Hi, I follow each step that is in your article, but i got this 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:\Program Files\Java\jdk1.7.0_04\jre\bin\jri.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1846)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at org.rosuda.JRI.Rengine.(Rengine.java:19)
at com.spontecorp.rjava.rtest.main(rtest.java:61)
Java Result: 1
I'm running on Windows 7 64 bits, JDK 1.7_04, Netbeans 7.2
I read and apply every sujestion that I founded in google, but nothing, always the same error.
By, the way ¿it is normal that rjava was installed in a different directory where R is installed?. I used the command install.packeges("rjava") and was installed automatically in a different directory, any way I setted this VM option; -Djava.library.path=C:\Users\Casper\Documents\R\win-library\2.15\rJava\jri\x64.
I´ll appreciate any help
Post a Comment