-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKlient.java
More file actions
40 lines (32 loc) · 1.11 KB
/
Copy pathKlient.java
File metadata and controls
40 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
public class Klient {
public static void main(String[] args) {
if (args.length != 3) {
System.out
.println("parametry: //host/nazwa pierwsza_liczba druga_liczba");
System.exit(0);
}
String nazwa = args[0];
long a = Long.parseLong(args[1]);
long b = Long.parseLong(args[2]);
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
Interfejs interfejs = null;
try {
interfejs = (Interfejs) Naming.lookup(nazwa);
long wynik = interfejs.obliczNWD(a, b);
System.out.println("NWD (" + a + "," + b + ") = " + wynik);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (NotBoundException e) {
e.printStackTrace();
}
}
}