To make things a bit easier, this hunk of code:
> // start up remote server
> System.out.println("Starting remote server...");
> RemoteServerImpl rsi = null;
> try {
> rsi = new RemoteServerImpl();
> Naming.rebind("///" + server, rsi);
> }
> catch (java.rmi.ConnectException exc) {
> System.err.println("Please run rmiregistry first.");
> System.exit(-2);
> }
> catch (MalformedURLException exc) {
> System.err.println("Error binding server; try a different name.");
> System.exit(-3);
> }
> catch (RemoteException exc) {
> System.err.println("Error binding server:");
> exc.printStackTrace();
> System.exit(-4);
> }
> rsi.addDataReference(ref);
can be rewritten as:
System.out.println("Starting remote server...");
RemoteServerImpl rsi;
try {
visad.util.ClientServer.startServer(server);
}
catch (Exception exc) {
System.err.println("Error creating server:");
exc.printStackTrace();
System.exit(-1);
return;
}
rsi.addDataReference(ref);
In addition to being a bit shorter, this code will
automatically start an 'rmiregistry' server if one is not
yet running.