i'm trying to create a basic hello world for rmi .
server code:
import java.net.InetAddress; import java.net.MalformedURLException; import java.net.UnknownHostException; import java.rmi.AlreadyBoundException; import java.rmi.Naming; import java.rmi.RMISecurityManager; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class server extends UnicastRemoteObject implements dostuff{ protected server() throws RemoteException { } public static void main(String args[]) { System.setSecurityManager(new RMISecurityManager()); try { String computername=InetAddress.getLocalHost().getHostName(); server s = new server(); try { Naming.bind("//"+computername+"/server", s); System.out.println("server started"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (AlreadyBoundException e) { e.printStackTrace(); } } catch (RemoteException e) { e.printStackTrace(); } catch (UnknownHostException e) { e.printStackTrace(); } } @Override public String doesitwork() { return "yes"; } }
interface:
import java.rmi.*; interface dostuff extends Remote{ public String doesitwork() throws RemoteException; }
i run the server in eclipse with VM arguments -Djava.rmi.server.codebase=${container_loc} -Djava.security.policy policy.txt. the policy just gives all permissions.
i get the exception
Java.rmi.unmarshalException Error unmarshalling return; nested exception is:
java.net.malformedURLException: unknown protocol g
etc.
the external hard drive my java projects is on shows up as G:.
what's the problem here?