RServe Java Source R script


There are two ways to source R script file in RServe Java program. The first way is to directly source it in the java code. The only disadvantage of this method is that each connection would need to do this. As an example consider the following R code

To source it directly in java

Another way to source palindrome.R is via the RServe.conf file. The file is present at /etc/Rserve.conf. If the file is not present then create a new one. Add the following line in the Rserve.conf file

If the default file is not used then specify the file on the command line

The java code remains same except that line 11 in the code above is deleted.

RServe Java Source R script

2 thoughts on “RServe Java Source R script

  1. Hi Mithil,
    Its a great example to get started with RServe. I was able to send the commands to be executed on the remote R server, but I wanted to execute a R script present in a remote location itself. Is that possible through Rserve? If yes, how?

  2. Hi,
    Thank you for the post. I have sourced the R script in my remote machine’s Rserv.conf file. But when executing I get the error :
    org.rosuda.REngine.Rserve.RserveException: eval failed, request status: error code: 127
    at org.rosuda.REngine.Rserve.RConnection.eval(

    on this this line: c.eval(“palindrome(‘aba’)”);

    Why is it not reading the function from the sourced script, I’m wondering. FYI I didnt get any error in starting the Rserve with this conf file and the function is present in the script.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top