0

The basic set-up is to have a Java based UI and R running in the background. Rserve utility helps to address this kind of a situation.

It's known that Rserve, although not a package, but can be installed and run like a normal R package. A simple library(Rserve) will invoke it and in the Windows Task Manager, you see the process up and running.

However, there is another way around, without having to go to R console frequently, by writting a script in Java itself.

/**
     * initiate R serve
     */
    try {
        Process p=Runtime.getRuntime().exec("R CMD Rserve --vanilla"); //I'm stuck here
        p.waitFor();
    } catch (IOException e1) {
        e1.printStackTrace();
    } catch (InterruptedException e2) {
        e2.printStackTrace();
    } 

The problem is, R CMD Rserve --vanilla is not working. It says,

`Rserve` is not recognised as internal or external command. 

My R CMD is perfect, R is working good, so is Rscript but not Rserve. I wish to know how do I set the appropriate directory/path for Rserve within the R installation, so that I resolve this error?

sunitprasad1
  • 768
  • 2
  • 12
  • 28
  • Isn't it only designed for unix environment? –  Apr 17 '15 at 05:26
  • Well their official release document at https://rforge.net/Rserve/ of 2003 reads : "2013/08/21 Rserve 1.7-3 released. This relase now restores Windows support (thanks to David Champagne from Revolution Analytics!), it allows HTTPS to WebSockets/TLS upgrade (on unix) and cleans up configuration of the various new possible server configurations." – sunitprasad1 Apr 17 '15 at 06:58
  • From the January 19, 2015 documentation: `"R CMD Rserve will only work on unix when installed from sources and with sufficient permissions to have write-rights in $R_HOME/bin. Binary installations have no way to write in $R_HOME/bin and thus Rserve() function described above is the only reliable way to start Rserve in that case. Java developers may want to see the StartRserve class in java/Rserve/test examples for easy way to start Rserve from Java."` –  Apr 17 '15 at 07:01
  • Well, that escalated quickly. – sunitprasad1 Apr 17 '15 at 09:49

1 Answers1

1

I realise this question is from way back, but I feel an answer is still warranted for those that are interested.

Following the suggestion:

Binary installations have no way to write in $R_HOME/bin and thus Rserve() function described above is the only reliable way to start Rserve in that case.

Instead of using

R CMD Rserve

use

Rscript -e "library(Rserve); Rserve()"

Also, for those that were mystified by the comment in the Rserve documentation (?Rserve) about the line:

Java developers may want to see the StartRserve class in java/Rserve/test examples for easy way to start Rserve from Java.

You can find the class in https://rforge.net/Rserve/snapshot/Rserve_1.8-8.tar.gz by extracting the contents and navigating to ./clients/java/Rserve/test/StartRserve.java.

byrongibby
  • 55
  • 1
  • 7