Java RMI : connection refused

Posted by mihsathe on Stack Overflow See other posts from Stack Overflow or by mihsathe
Published on 2011-02-21T15:14:48Z Indexed on 2011/02/21 15:25 UTC
Read the original article Hit count: 317

Filed under:
|

I have written following code for the client of RMI. But getting

java.rmi.ConnectException: Connection refused to host: localhost; nested 
exception is:
    java.net.ConnectException: Connection refused: connect

code :

import java.rmi.*;
import java.net.*;
import java.rmi.registry.*;

class client
{
    public static void main(String [] ars)
    {
        Iface serv;
        Registry r;
        String serveraddr = ars[0];
        String serverport = ars[1];
        String text = "Hey jude";

        System.out.println("Sending" + text);

        try{
            r = LocateRegistry.getRegistry(
            serveraddr,
            (new Integer(serverport)).intValue()
            );
            serv = (Iface) r.lookup("rmi://server");

            serv.receive(text);
        }
        catch(Exception e){
            System.out.println(e);
        }
    }   
}

© Stack Overflow or respective owner

Related posts about java

Related posts about rmi