السلام علكيم
انا كتبت RMI سيرفر و كلينت علما انهم في جهازين مختلفين و لكن يحدث خطأ في الاتصال , لا اعلم ما السبب ConnectionException (timeout
سيرفر
import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
/**
*
* @author NEW
*/
interface ServerInterface extends Remote
{
public String Display()
throws RemoteException;
}
public class Server extends UnicastRemoteObject implements ServerInterface{
private static String Message="Welcome to our server";
public Server() throws RemoteException {
super();
}
public String Display() throws RemoteException {
return Message;
}
public static void main(String[]args) throws RemoteException
{
try
{
Server obj=new Server();
Naming.bind("service", obj);
}
catch (RemoteException e)
{
System.out.println(""+e.getMessage());
}
catch (AlreadyBoundException e)
{
System.out.println(""+e.getMessage());
}
catch (MalformedURLException e)
{
System.out.println(""+e.getMessage());
}
}
}كلينت
import java.rmi.Naming;
import java.rmi.Remote;
import java.rmi.RemoteException;
interface ServerInterface extends Remote
{
public String Display()
throws RemoteException;
}
/**
*
* @author NEW
*/
public class Client {
public static void main (String args[])
{
try
{
ServerInterface handle=(ServerInterface)Naming.lookup("rmi://newtech-pc/service");
System.out.println(handle.Display());
}
catch (Exception e)
{
System.out.println(""+e.getMessage());
}
}
}و هل يمكنني تشغيل واجهة في حهاز الكلينت و هي مكتوبة في السيرفر عن طريق RMI ؟؟؟؟



