当我尝试通过Java运行R程序时,我遇到了异常。虽然连接已经建立,但是在R代码评估开始时出现错误。
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
我已经在 R
中启动了 Rserve
。
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)