Java Reference
In-Depth Information
}
try
{
Hello greeting =
(Hello)Naming.lookup(
"rmi://" + HOST + "/Hello");
System.out.println("Message received: "
+ greeting.getGreeting());
}
catch(ConnectException conEx)
{
System.out.println(
"Unable to connect to server!");
System.exit(1);
}
catch(Exception ex)
{
ex.printStackTrace();
System.exit(1);
}
}
}
When executing the server, we need to specify where the required .class fi les are
located, so that clients may download them. To do this, we need to set the java.rmi.
server.codebase property to the URL of this location, at the same time that the server
is started. This is achieved by using the -D command line option to specify the setting
of the codebase property. For example, if the URL of the fi le location is http://java.
shu.ac.uk/rmi/ , then the following line would set our HelloServer program running
and would set the codebase property to the required location at the same time:
java -Djava.rmi.server.codebase=http://java.shu.ac.uk/
rmi/ HelloServer
It is very easy to make a slip during the above process that will cause the application
to fail, but coverage of these problems goes beyond the scope of this text.
Search WWH ::




Custom Search