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]libraryrJavajri and (ii) [R_HOME]bin
That’s it. Right click on rtest.java and click on ‘Run File’.
R and Java – JRI Using Netbeans