views:

29

answers:

2

Hello.

I am doing a student assignment, using java RMI. I've programmed a simple RMI-server application that provides method which return some strings to the client.

When I start the server on localhost and connect to it by client on the same computer, everything goes well.

However, I am not able to do this between two computers on home network. The computers both have no trouble of connecting by a simple C program with similar functionality, so I guess the problem is with JVM here.

I am binding the class to rmiregistry with

try{
ComputeImpl R = new ComputeImpl(); 
Naming.rebind("rmi://localhost/ComputeService",R);
}
catch(Exception e){
System.out.println("Trouble: " +e);
}

And I'm doing the lookup for RMI registry in the client application with providing the argument while launching the application:

StringBuffer rmi_address = new StringBuffer();      
rmi_address.append("rmi://").append(args[1]).append("/ComputeService");
Compute R = (Compute) Naming.lookup(rmi_address.toString());

Is the problem with my code or with JVM?

Thanks in advance.

A: 

You need to bind it to the public hostname or ip of the computer, not to localhost. And I'm surprised why there arent any SecurityException(s). You need to add some things to the security policy to get rmi working

Midhat
The same happens when i bind it to ip address of the computer.I've tried launching it as "java -Djava.security.policy=java.security.AllPermission computeclient 192.168.1.35" also but didn't work
Hippopotamus
A: 

The issue and the answer to this issue is better described in this post http://stackoverflow.com/questions/2624752/starting-rmi-server-on-ubuntu-laptop/2624903#2624903

Hippopotamus