Mensagm com RMI (dukejfree)

1 resposta
oliveirarenan

Olá, eu estava fazendo uns testes aqui com RMI.
Não segui as suas orientações, tentei fazer uma coisa mais simples.
Veja no que deu:

Tenho uma classe chamada app:

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class App extends UnicastRemoteObject implements Server
{
	private String nome, netsend;

	public App() throws RemoteException
	{

	}

	public static void main(String args[])
	{
		try
		{

			App app = new App();
			//app.netSend(args[0], args[1]);
			Naming.rebind("//172.18.1.56/app", app);
		}
		catch (RemoteException re)
		{
			System.out.println("Remote Exception ->" + re);
		}
		catch (MalformedURLException me)
		{
			System.out.println("MalformedURLException -> " + me);
		}
	}

	/**
	 * Gets the nome
	 * @return Returns a String
	 */
	
	public void netSend(String maq, String msg)
	{
		try
		{
			Runtime.getRuntime().exec("NET SEND "+maq + " " + msg);
		}
		catch(IOException ie)
		{
			System.out.println("IOException ->" + ie);
		} 
	}
}

dai eu tenho as classes cliente e server:

import java.rmi.Naming;
import java.rmi.RMISecurityManager;

public class Cliente
{

	private static Server server;

	public static void main(String[] args)
	{
		try
		{
				server = (Server) (Naming.lookup("//172.18.1.56/app"));
				server.netSend(args[0], args[1]);
		}
		catch (Exception e)
		{
			System.out.println("RemoteException =>" + e);
		}
	}
}

...

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Server extends Remote
{
	public void netSend(String maq, String msg) throws RemoteException;
}

Bem, mas esta dando um erro na classe server...não sei se esta correto.....
o erro é o seguinte, quando eu tento compilar o cliente, ele aparece o seguinte erro:

Cliente.java:9: cannot resolve symbol
symbol  : class Server
location: class Cliente
        private static Server server;
                       ^
Cliente.java:15: cannot resolve symbol
symbol  : class Server
location: class mdrmiteste.Cliente
                                server = (Server) (Naming.lookup("//172.18.1.56/
app"));
                                          ^
2 errors

e quando eu tento compilar a classe app, ele da o erro:

App.java:9: cannot resolve symbol
symbol  : class Server
location: class App
public class App extends UnicastRemoteObject implements Server
                                                        ^
1 error

ou seja, o mesmo erro do cliente....

cara, me ajuda por favor, pq eu to apanhando..ehehehehe

falowwww e valeuuuuu

1 Resposta

dukejeffrie

Pode me chamar de Duke… 8)

Cara, seu problema é muito simples, e o javac te explicou direitinho o que tem de errado:

Cliente.java:9: cannot resolve symbol
symbol  : class Server
location: class Cliente

No arquivo Cliente.java, na linha 9, tem um símbolo que ele não consegue saber o que significa.

No caso, vc declara uma interface que ele não conhece. Provavelmente seu problema é de pacote!! Como você declarou a interface Server??

Criado 2 de abril de 2003
Ultima resposta 2 de abr. de 2003
Respostas 1
Participantes 2