package client; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import compute.Compute; public class ComputeName { public static void main(String args[]) { if (System.getSecurityManager() == null) { System.setSecurityManager(new SecurityManager()); } try { String name = "Compute"; Registry registry = LocateRegistry.getRegistry(args[0]); Compute comp = (Compute) registry.lookup(name); Name task = new Name(args[1]); String pi = comp.executeTask(task); System.out.println("Bonjour "+pi); } catch (Exception e) { System.err.println("ComputePi exception:"); e.printStackTrace(); } } } package client; import compute.Task; import java.io.Serializable; public class Name implements Task, Serializable { private static final long serialVersionUID = 227L; /** digits of precision after the decimal point */ private String digits; /** * Construct a task to calculate pi to the specified * precision. */ public Name(String name) { this.digits = name; } /** * Calculate pi. */ public String execute() { return computeName(this.digits); } public static String computeName(String x) { return x; } }