Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Same interface i have in my server computer.*/
- package remoto;
- import java.rmi.Remote;
- import java.rmi.RemoteException;
- public interface Mensageiro extends Remote {
- void enviarMensagem(String msg) throws RemoteException;
- String lerMensagem() throws RemoteException;
- }
- /**********************************************************************************************/
- import remoto.*;
- import java.rmi.registry.LocateRegistry;
- import java.rmi.registry.Registry;
- import java.rmi.RemoteException;
- import java.rmi.NotBoundException;
- public class MensageiroCliente {
- public static void main(String[] args) {
- try {
- Registry registry = LocateRegistry.getRegistry("192.168.1.102");
- Mensageiro m = (Mensageiro) registry.lookup("MensageiroServer");
- String resposta = m.lerMensagem();
- System.out.println("Resposta do Server: " + resposta);
- } catch (RemoteException e) {
- System.out.println();
- System.out.println("RemoteException: " + e.toString());
- } catch (NotBoundException e) {
- System.out.println();
- System.out.println("NotBoundException: " + e.toString());
- } catch (Exception e) {
- System.out.println();
- System.out.println("Exception: " + e.toString());
- }
- }
- }
- /**********************************************************************************************/
- Error1:
- NotBoundException: java.rmi.NotBoundException: MensageiroServer
- /**********************************************************************************************/
- Error2: Changing a little bit the string of LocateRegistry.getRegistry and adding the port "192.168.1.102:1099"
- RemoteException: java.rmi.UnknownHostException: Unknown host: 192.168.1.102:1099; nested exception is:
- java.net.UnknownHostException: 192.168.1.102:1099
- /**********************************************************************************************/
- I'm using Mint, with NetBeans 6.9 and typing java -version in terminal it appears:
- java version "1.6.0_20"
- OpenJDK Runtime Environment (IcedTea6 1.9.13) (6b20-1.9.13-0ubuntu1~10.10.1)
- OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement