I'm programming a simple system, using RMI, to train programming. But I encountered some problems when I created the .batch file by inserting the message into 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 program code also to be analyzed and see if there is any relation
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();
}
Implementing 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);
}
}
}