Search code examples
javarrjavarserve

R integration with Java


I am using some R script in my Java program.

To integrate R with Java, i found two techniques RJAVA and RSERVE.

I am not able to understand which one should i use
and how much these two are different.

I think RSERVE just talks to R server via connection
but what about RJAVA.

It would great help somebody clear my doubts in here.

Thanks.


Solution

    1. rServe is a client-server communication, the R code runs on server and client(here java) gets the results, using usual TCP/IP connection (can also run locally).
    2. rJava is more like a API library to R in java. The R code runs on your locally installed R instance.

    selecting one of them is based on your needs. If you want to embed a small amount of R code in java then rJava is the correct choice. If you have large amount of R codes in multiple scripts, or if you want them to be exposed as REST API to multiple java clients then rServe is the way to go.