FileDocCategorySizeDatePackage
Client_3.javaAPI DocExample938Sun Mar 07 08:34:44 GMT 1999com.titan.ship

Client_3.java

package com.titan.ship;

import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import java.rmi.RemoteException;
import java.util.Properties;
import java.util.Enumeration;

public class Client_3{
    public static void main(String [] args){
        try{
            Context ctx = getInitialContext();
            ShipHome home = (ShipHome)ctx.lookup("ShipHome");

            Enumeration enum = home.findByCapacity(4500);
            while(enum.hasMoreElements()){
                Ship aShip = (Ship)enum.nextElement();
                System.out.println(aShip.getName());
            }

        }catch(Exception e){e.printStackTrace();}
    }
    public static Context getInitialContext() throws Exception {
        Properties p = new Properties();
        // ... specify the JNDI properties specific to the vendor
        return new InitialContext(p);
    }
}