【Java开源代码栏目提醒】:网学会员Java开源代码为您提供Client2.java参考,解决您在Client2.java学习中工作中的难题,参考学习。
import java.net.MalformedURLException;
import java.rmi.*;
class Client2 {
private static final int TIMEOUT_INTERVAL = 30000;
private Server2IF server;
private HeartbeatListener heartbeatListener;
/**
* Main logic for client.
*/
public static void main(String[] argv) {
if (argv.length==0) {
usage();
} // if
try {
new Client2(argv[0]).start();
} catch (Exception e) {
e.printStackTrace();
} // try
System.exit(0);
} // main(String[])
/**
* Explain proper usage to the client.
*/
private static void usage() {
System.out.println("Usage is \nclient serverName");
System.exit(1);
} // usage()
/**
* Constructor
* @param serverHost The name of the host that the
* server runs on.
*/
Client2(String serverHost) throws RemoteException,
UnknownHostException,
NotBoundException,
MalformedURLException {
String urlName = "//" + serverHost
+ "/" + Server2IF.SERVER_NAME;
server = (Server2IF)Naming.lookup(urlName);
} // Constructor(String)
/**
* This method is responsible for starting whatever the client does.
*/
private void start() {
//...
try {
server.doIt();
} catch (HeartbeatException e) {
//...
} catch (RemoteException e) {
e.printStackTrace();
//...
} // try
//...
} // start
} // class Client2
上一篇:
client1.java
下一篇:
ASP小区停车管理系统(Access)(含录像)