This is the code I am working with:
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");
}
}
This is the exception I am getting :
Connection exception is thrown...Cannot connect: Connection timed out: connect org.rosuda.REngine.Rserve.RserveException: Cannot connect: Connection timed out: connect at 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) Exception in thread "main" java.lang.NullPointerException at com.sc.SimpleR.main(SimpleR.java:20)
The code is working fine for local Rserve.
I tried this: Running R Code remotely from java application but no luck. Please help.Thanks in advance