这是我正在使用的代码:
public class SimpleR {
public static void main(String args[])
{
RConnection re = null;
try {
re = new RConnection("192.168.1.151",6311);
//re = new RConnection("localhost",6311);
} catch (RserveException e) {
System.out.println("Connection exception is thrown..."+e.getMessage());
e.printStackTrace();
}
if(re.isConnected())
System.out.println("Connection established....");
else
System.out.println("Can not establish connection");
}
}
这是我得到的例外:
抛出连接异常...无法连接:连接超时: connect org.rosuda.REngine.Rserve.RserveException:无法连接: 连接超时:连接到 org.rosuda.REngine.Rserve.RConnection。(RConnection.java:88)at org.rosuda.REngine.Rserve.RConnection。(RConnection.java:60)at com.sc.SimpleR.main(SimpleR.java:14)线程中的异常" main" java.lang.NullPointerException at com.sc.SimpleR.main(SimpleR.java:20)
该代码适用于本地Rserve。
我试过这个:Running R Code remotely from java application但没有运气。 请帮忙。谢谢提前