String name = args[0];
try {
// Get a JNDI context for our EJB server (EJBHome, in this case)
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ejbhome.naming.spi.rmi.RMIInitCtxFactory");
// Add URL, host or port options, if needed...;
Context context = new InitialContext(p);
// Get the home interface for Person beans
PersonHome pHome =
(PersonHome)context.lookup("People");
// Create a named person
Person person = pHome.create(name);
// Use the remote stub interface to access the person’s data
// . . .
}
catch (NoSuchPersonException nspe) {
System.out.println("Invalid person: " + name);
}
catch (Exception e) {
System.out.println("Error while creating/using person.");
}