Site icon R-bloggers

R and Java – JRI Using Netbeans

[This article was first published on R – StudyTrails, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Setting up R-Java in Netbeans is pretty straight forward. For those who need a walkthough here are the steps.
  1. Download and install R (for this example version 2.12.2). install rJava package. 
  2.  Download and install Netbeans. 
  3. In Netbeans Create a new java project. we will call it RJava.
  4.  From the [R_HOME]>/library/rJava/jri/examples folder, copy the file rtest.java into the project.
  5. 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
  6. 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.
  7. 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’.

To leave a comment for the author, please follow the link and comment on their blog: R – StudyTrails.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.