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)

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 )

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();
		}

		
	}

}

Can Anyone help me in this problem ?

Thanks

It would print something after demo3 IF you had written

e.printStackTrace();
// instead of
e.fillInStackTrace();
// on line 56
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.