Boa Noite, eu também estou tentando rodar minha aplicação e também está dando erro do tipo:
Erro:java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
O meu CLIENTE roda normalmente, mas quando vai acessar o SERVIDOR, dá esse erro.
Já tentei fazer várias coisas e mesmo assim ainda não consegui, se alguem puder me ajudar, ficarei muito Feliz.
Abaixo segue meu código,
Bjos,
Rebecca
SERVIDOR
view plaincopy to clipboardprint?
    /* 
    * To change this template, choose Tools | Templates 
    * and open the template in the editor. 
    */  
    package rmi;  
    import java.rmi.Naming;  
        import java.rmi.RemoteException;  
           
    /** 
    *  
    * @author Rebecca 
    */  
    public class Servidor  
        {  
                /** 
                 *  
                 * @throws RemoteException 
                 */  
                public Servidor() throws RemoteException  
            {  
                String localServico = "rmi://localhost:1099/InterfaceCalculoRemoto";  
                InterfaceCalculoRemoto objServidorRemoto = new ImplementacaoCalculoRemoto();  
           
                try  
                {  
                     Naming.rebind(localServico, objServidorRemoto);  
                }  
                catch (Exception e)  
                {  
                     e.printStackTrace();  
                }  
             }  
           
                /** 
                 *  
                 * @param args 
                 * @throws RemoteException 
                 */  
                public static void main(String[] args) throws RemoteException  
                {  
                      Servidor objServidor = new Servidor();  
                }  
        }  
CLIENTE
view plaincopy to clipboardprint?
    /* 
    * To change this template, choose Tools | Templates 
    * and open the template in the editor. 
    */  
    package rmi;  
      
    import java.net.MalformedURLException;  
        import java.rmi.Naming;  
        import java.rmi.NotBoundException;  
        import java.rmi.RemoteException;  
        import javax.swing.JOptionPane;  
      
           
    /** 
    *  
    * @author Rebecca 
    */  
    public class Cliente {  
           
        /** 
         *  
         * @param args 
         */  
        public static void main(String[] args)  
            {  
                try {  
                       int val1 = Integer.parseInt(JOptionPane.showInputDialog("Entre com o primeiro valor"));  
                       String opcao[] = {"+", "-", "*", "/"};  
           
                       int operacao = JOptionPane.showOptionDialog(null, "Escolha uma das operacoes", "Tipo de operacao",  
                       0, JOptionPane.INFORMATION_MESSAGE, null, opcao, opcao[0]);  
           
                       int val2 = Integer.parseInt(JOptionPane.showInputDialog("Entre com o segundo valor"));  
           
                       InterfaceCalculoRemoto objCalculoRemoto = (InterfaceCalculoRemoto)Naming.lookup("rmi://localhost:1099/InterfaceCalculoRemoto");  
           
                       System.out.println("Servidor fala: O resultado é = " + objCalculoRemoto.metodo_calcular(val1, val2, operacao));  
                       objCalculoRemoto.mensagemServidor("Recebi a Resposta");  
                 }  
           
                    catch (MalformedURLException e)  
                    {  
                            System.out.println("Erro:" + e.toString());  
                            e.printStackTrace();  
                    }  
                    catch (RemoteException e)  
                    {  
                            System.out.println("Erro:" + e.toString());  
                            e.printStackTrace();  
                        }  
                    catch (NotBoundException e)  
                    {  
                            System.out.println("Erro:" + e.toString());  
                            e.printStackTrace();  
                        }  
                    catch (Exception e)  
                    {  
                            JOptionPane.showMessageDialog(null, "Entrada inválida", e.getMessage(), JOptionPane.ERROR_MESSAGE);  
                            System.exit(-1);  
                    }  
            }  
    }  
IMPLEMENTAÇÃO CALCULOREMOTO
view plaincopy to clipboardprint?
    /* 
    * To change this template, choose Tools | Templates 
    * and open the template in the editor. 
    */  
    package rmi;  
      
    import java.rmi.RemoteException;  
        import java.rmi.server.UnicastRemoteObject;  
           
    /** 
    *  
    * @author Rebecca 
    */  
    public class ImplementacaoCalculoRemoto extends UnicastRemoteObject implements InterfaceCalculoRemoto  
        {  
          
        /** 
         *  
         * @throws RemoteException 
         */  
        public ImplementacaoCalculoRemoto() throws RemoteException  
            { }  
           
                /** 
                 *  
                 * @param mensagem 
                 * @throws RemoteException 
                 */  
        @Override  
                public void mensagemServidor(String mensagem) throws RemoteException  
        {  
              System.out.println("Cliente fala: " + mensagem);  
        }  
           
                /** 
                 *  
                 * @param val1 
                 * @param val2 
                 * @param op 
                 * @return 
                 * @throws RemoteException 
                 */  
        @Override  
                public double metodo_calcular(int val1, int val2, int op) throws RemoteException  
        {  
           double v1 = Double.valueOf(String.valueOf(val1));  
           double v2 = Double.valueOf(String.valueOf(val2));  
           
              if (op == 0)  
              {  
                  return (v1 + v2);  
              }  
              else  
                  if (op == 1)  
                  {  
                      return (v1 - v2);  
                  }  
                  else  
                      if (op == 2)  
                      {  
                          return (v1 * v2);  
                      }  
                      else  
                           if (op == 3)  
                           {  
                               return (v1 / v2);  
                            }  
             return 0;  
          }  
    }  
INTERFACE CALCULOREMOTO
view plaincopy to clipboardprint?
    /* 
    * To change this template, choose Tools | Templates 
    * and open the template in the editor. 
    */  
    package rmi;  
      
    import java.rmi.Remote;  
        import java.rmi.RemoteException;  
           
    /** 
    *  
    * @author Rebecca 
    */  
    public interface InterfaceCalculoRemoto extends Remote  
        {  
                /** 
                 *  
                 * @param val1 
                 * @param val2 
                 * @param operacao 
                 * @return 
                 * @throws RemoteException 
                 */  
                public double metodo_calcular(int val1, int val2, int operacao) throws RemoteException;  
                /** 
                 *  
                 * @param mensagem 
                 * @throws RemoteException 
                 */  
                public void mensagemServidor(String mensagem) throws RemoteException;  
        }  
Fico no aguardo, Obrigada