Results 1 to 1 of 1
Thread: RMI qusetion
- 03-24-2011, 02:54 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 28
- Rep Power
- 0
RMI qusetion
Hello,
I wrote a program by RMI, when I compile it by the cmd, the client class dosn"t compiled, it"s arrive to the lookup and stop.
this is part of my code:
Client Class: (the lookup doesn"t succeeded, when i compile it, print demo 1 , demo 2 and demo 3 but without demo 4)
Java Code:import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.rmi.Naming; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class BackupClient { final static String HOST = "localhost"; /** * @param args */ public static void main(String[] args) { BackupServer rmiServer; Registry registry; try { URL url = new URL(args[0]); System.out.println("demo 1"); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String clientName = args[1]; String rootDirectory = args[2]; System.out.println("demo 2"); if(args.length != 3) { System.out.println("sasas"); System.exit(1); } try { String objectName = "rmi://" + HOST; System.out.println("demo 3"); // get reference to the BackupServer BackupServer server = (BackupServer) Naming.lookup(objectName); System.out.println("demo 4"); UserBackup usrBackup= server.getUserBackup(clientName); RemoteCopy rc = usrBackup.getCopy(rootDirectory); File rootDir = new File (rootDirectory); File []files= rootDir.listFiles(); } catch (Exception e){ e.fillInStackTrace(); } } }
the server class: (on the server the rebind succeeded )
Can Anyone help me in this problem ?Java Code:import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class BackupServerImpl extends UnicastRemoteObject implements BackupServer { final static String HOST = "localhost"; protected BackupServerImpl() throws RemoteException { super(); // TODO Auto-generated constructor stub } public UserBackup getUserBackup(String username) throws RemoteException{ return null; } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { String objectName = "rmi://" + HOST; BackupServer service = new BackupServerImpl(); Naming.rebind("server", service); System.out.println("server ready"); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Thanks


LinkBack URL
About LinkBacks

Bookmarks