Reputation: 768
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?
Upvotes: 0
Views: 418
Reputation: 65
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.
Upvotes: 1