Solution 1:

I have successfully used two alternatives in the past.

JRI

  • Pros: probably better performance.
  • Cons: you have to configure some environment variables and libraries, different in Win/UNIX.

RServe

  • Pros: easy to setup, you don't need to initialize R or link against any R library, can run in a different machine.
  • Cons: based on TCP/IP (a server is running), no callbacks from R.

Other alternatives I have never used : RCaller

Solution 2:

There has been work by Duncan Temple Lang: http://rss.acs.unt.edu/Rdoc/library/SJava/Docs/RFromJava.pdf .

My guess as to the most robust solution would be JGR. The developers of JGR have a mailing list, Stats-Rosuda and the mailing list Archive indicates the list remains active as of 2013.

There is also code that has been put up at Googlecode, with an example here: http://stdioe.blogspot.com/2011/07/rcaller-20-calling-r-from-java.html

Solution 3:

This is an old question.. but for anyone browsing through here that is still interested: I wrote a blog article that provides a detailed example of how to use JRI/rjava (a JNI based bridge) to do this type of thing (the how-to is focused on Linux dev environments). I also compare and contrast alternative approaches for doing 'mathy' stuff by calling out to R and similar frameworks.

URL > http://buildlackey.com/integrating-r-and-java-with-jrirjava-a-jni-based-bridge/

Solution 4:

Renjin is an alternative that allows not only the integration of many packages of R also a easy going communication between Java and R through objects:

http://www.renjin.org/