Nęste
Forrige
Oversigt
RMI, JDBC og Servlets - dag 5 serie, Planche nr. 21
Kursus Indhold

ComputePi

 
package client;

import java.rmi.*;
import java.math.*;
import compute.*;

public class ComputePi {
    public static void main(String args[]) {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        try {
            String name = "//" + args[0] + "/Compute";
            Compute comp = (Compute) Naming.lookup(name);
            Pi task = new Pi(Integer.parseInt(args[1]));
            BigDecimal pi = (BigDecimal) (comp.executeTask(task));
            System.out.println(pi);
        } catch (Exception e) {         
            System.err.println("ComputePi exception: " + e.getMessage());
            e.printStackTrace();
        }
    } 
}


© 2000 BLA*net - Leif E. Andersen, leander@blanet.dk
Nęste
Forrige
RMI, JDBC og Servlets - dag 5 serie, Planche nr. 21