RServe – Introduction and Installation

September 13, 2016

(This article was first published on R – StudyTrails, and kindly contributed to R-bloggers)

Related Tutorials

First Sample Program


RServe is an R package that allows other applications to talk to R using TCP/IP. It creates a socket server to which other applications can connect. RServe provides client implementation for common languages such as C/C++, Java and PHP. In this series of tutorials we will look at how to use java to make calls to R using RServe. Features of RServe are ::

  • RServe can be started without starting R. There is no need to initialize R or link to the R libraries
  • The java client is present in src/client/java-new
  • The default port for RServe is 6311
  • The R objects are transferred as binary object between the server and the client. Files can be transferred between the client and the server
  • Each connection has its own working directory and namespace.
  • The client converts R objects to java objects. The java client has classes such as RBool, RList etc.
  • multiple connections can access RServe in thread-safe manner. However, multiple eval calls using the same connection are not thread safe.

Platform – Windows of linux?

RServe can be installed on both windows and linux platform, however it is recommended to install and use it on a linux platform. To use R with java on a single windows machine it would be better to use the native client JRI instead. The RJava Eclipse Plugin can be used to set up JRI for use within a single windows machine. However, if you are looking for an enterprise level solution that supports multi-threading then RServe is a better choice.

Installation and Starting RServe

Installing RServe is very simple. Start R and on the command prompt type in install.packages(“RServe”,dest=”<DEST_DIR>”). The DEST_DIR stores the RServe source package. We will need this to get the java client. This will download and install RServe.

RServe can be started in two ways

    • Directly from R. On the R console type library(“Rserve”). This will load RServe
    • On the console type Rserve(). This will start RServe in daemon mode. Note that R does not have to be running in order to use RServe. You can quit the R console and RServe will still run.
    • Since RServe runs as a daemon, you can shut it down gracefully from the client (we shall see that later). However, to explicitly kill RServe on a linux box, type in ps -ef | grep Rserve. Look for the RServe process. you should see something like <R_HOME>Rserve/libs// Note down the process id and kill the process using kill -9 process_id
  1. From the unix console. Start RServe using the command R CMD RServe. This will again start RServe as a daemon.

The post RServe – Introduction and Installation appeared first on StudyTrails.

To leave a comment for the author, please follow the link and comment on their blog: R – StudyTrails. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)