I am getting an exception while trying to run a R program via Java. The connection is being established but then the error is being thrown while the evaluation of the R code starts.
Rconnection connection = new RConnection();
System.out.println(String.valueOf(connection.isConnected())); //Output: True
connection.eval("source('C:\\Users\\Vini\\Documents\\test.R')"); //Exception in this line
I have already started the Rserve
in R
.
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.net.SocketInputStream.read(SocketInputStream.java:127)
at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:213)
at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:180)
at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:250)
at org.rosuda.REngine.Rserve.RConnection.eval(RConnection.java:231)
at integration.Integration.main(Integration.java:36)
org.rosuda.REngine.Rserve.RserveException: eval failed
at org.rosuda.REngine.Rserve.RConnection.eval(RConnection.java:234)
at integration.Integration.main(Integration.java:36)