Rmiregistry not found

Asked

Viewed 216 times

3

I am programming a simple system, using RMI, to train programming. However I found some problems when creating the file .batch receiving the message on the windows terminal

'rmiregistry' is not recognized as an Internal or External command, operable program or batch file.

I would like to know how I can solve this problem, if necessary I will be sending the code of the program also to be analyzed and see if there are any links


Client class

package Client;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.NotBoundException;
import java.net.MalformedURLException;
import Comum.IntDataHora;
import Comum.IntDataHoraImp;

public class ClienteDataHora
{
    public static void main(String[] args) 
    {
        try
        {
            IntDataHora mensagem = (IntDataHora) Naming.lookup(IntDataHoraImp.getUri());
            System.out.println(mensagem.getDatahora());
        }
        catch(MalformedURLException e)
        {
            System.out.println("Erro de formação da uri");
        }
        catch (RemoteException e)
        {
            System.out.println("Erro de comunicação");
        }
        catch (NotBoundException e)
        {
            System.out.println("epa! um erro!");
        }
    }
}

Interface

package Comum;

public interface IntDataHora
{
    public String getDatahora();
}

Implementation of the interface

package Comum;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Formatter;

public class IntDataHoraImp extends UnicastRemoteObject implements IntDataHora
{
    private static String servidor = "localhost";
    private static int porta = 1099;
    private static String servico = "DataHora";
    private int solicitacao = 0;

    public static String getUri()
    {
        String uri = String.format("rmi//%s:%d:%s", servidor,porta,servico);
        return uri;
    }
    public IntDataHoraImp()throws RemoteException
    {
        super();
    }

    @Override
    public String getDatahora()
    {

        GregorianCalendar atual = new GregorianCalendar(); 
        SimpleDateFormat formatacao = new SimpleDateFormat("dd' de 'MMMMM' de 'yyyy' - 'HH':'mm'h'");
        return formatacao.format(atual.getTime());

    }

}

Server class

package Servidor;
import java.rmi.Naming;
import Comum.IntDataHora;
import Comum.IntDataHoraImp;
import java.net.MalformedURLException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ServidorDataHora
{
    public ServidorDataHora() throws MalformedURLException
    {

        try
        {
             IntDataHora mensagem = new IntDataHoraImp();
            mensagem = new IntDataHoraImp();
            Naming.rebind(IntDataHoraImp.getUri(), (Remote) mensagem);
        } catch (RemoteException ex)
        {
            System.out.println("Erro:"+ ex);
        }

    }
}

Terminal print inserir a descrição da imagem aqui

  • Do you have the environment variables set ? ex: path environment variables

  • To be honest I don’t think I have. how can I set them up?

  • is on the link above, where I commented.

  • A echo %PATH% shows what?

  • @Dilneicunha thank you very much, problem solved!

  • 3

    @Luizcarlossimonard kindly post your solution as an answer, maybe help other people!

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.