R and Java – JRI Using Netbeans

September 30, 2011

(This article was first published on R – StudyTrails, and kindly contributed to R-bloggers)

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)