📄 showtimeclient.java
字号:
import java.rmi.*;
import java.rmi.server.*;
public class ShowTimeClient extends UnicastRemoteObject implements CallBackInterface {
int interval;
String time;
public ShowTimeClient(int n) throws RemoteException {
interval = n;
time = null;
}
public void updateTime(String str) throws RemoteException {
time = str;
System.out.println(time);
}
public int getInterval() throws RemoteException {
return interval;
}
public static void main(String[] args) {
int timeint = 5;
String address = "localhost";
if (args.length > 1) {
timeint = Integer.parseInt(args[0]);
address = args[1];
}
ShowTimeInterface remoteobjref = null;
try {
remoteobjref = (ShowTimeInterface) Naming.lookup("rmi://" + address + "/remoteobject");
System.out.println("Found Server.");
ShowTimeClient client = new ShowTimeClient(timeint);
remoteobjref.register(client);
} catch (Exception e) {
System.out.println("Client exception " + e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -