R is a powerful language for statistical computing and graphics. R has a strong community support and is finding new use in the corporate world. If R can be integrated with Java, it would provide a greap acceptance into new products. A library called rjava exists that helps integrate R with Java. However, setting up the library may be tricky.
This post explores how R can be called from within Java using JRI. We will use the example provided in the rjava package. The example class is called rtest2.java.
Here are the steps to run R from java using eclipse.
1) Create a new project and copy the rtest.java and rtest2.java files from the rjava/jri package. The rjava project folder can be found at the place where R stores the package downloaded during the install step. It should be in a folder called ‘win-library’.
That’s it. This should work. Run the rtest2 file and you should see R working.
Some of the steps above may not be required. However, i have found this to be working after some research and would not like to experiment further. Please add your comments if it works and also if it does not.