Reputation: 1911
I have a Java based web application running on server A. Now I want to integrate this Java web application with some R program on a remote server B.
What I want to achieve is as following. On Java side on server A, when a user want to see some data or charts, Java will figure out what kind of data is needed, then it need send appropriate request to remote server B and invoke some R code to run on B. When R code on B finishes, it will generated the data needed by A. It will send data to A. After getting the data, Java web app on A will take the data and generated some web views and present it on user's browser. How can I achieve this? Thanks in advance!
Upvotes: 1
Views: 289
Reputation: 4653
There is Rserve software that allows to use computer with R installed as remote computation server. There is also REngine Java client bundled with RServe that allows seamless integration of Rserve server and your Java code. Client has robust API and performs automatic type conversion between R and Java types.
After you install Rserve and put it's client on classpath of your Java code you can perform remote R computations as easy as
RConnection c = new RConnection("<your Rserve host>", <your Rserve port>);
double d[] = c.eval("rnorm(10)").asDoubles();
Upvotes: 2