assuming that you have R installed , bring up the R console by typing
R on console (in context of linux)
install.packages("Rserve")
library(Rserve)
Rserve()
Wait for final message at console as below
Rserv started in daemon mode.
import org.rosuda.JRI.Rengine;
import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.REngineException;
import org.rosuda.REngine.Rserve.*;
publi
cne; // initialized in constructor or autowired
try {
RConnection c = new RConnect
public void helloRWorld() throws REXPMismatchEx
cion();// make a new local connection on default port (6311)
org.rosuda.REngine.REXP x0 = c.eval("R.version.s
double d[] = c.eval("rnorm(10)").asDoubles();
tring");
System.out.println(x0.asString());
} catch (REngineException e) {
//manipulation
new RServerHel
}
}
public static void main(String[] args) throws REXPMismatchException {
RServerHello hwObj =
lo();
hwObj.helloRWorld();
}
}
Download RserveEngine.jar and include that as an external jar at configure build path (Right click on your file at project explorer -> Build Path --> configure build path).
Your java code now should be free of all errors
Run!!!
It should just work
No comments:
Post a Comment