www.pudn.com > ssd8-exc4.rar > RMIServer.java
import java.io.*;
import java.net.*;
import java.rmi.*;
public class RMIServer {
public static void main(String[] args) {
String hostname = "localhost";
int port = 0;
if ((args.length == 2)) {
hostname = args[0];
port = Integer.parseInt(args[1]);
} else {
System.out.println("Usage: Server hostname port");
System.exit(0);
}
try {
RMIClass Service = new RMIClass();
String registration = "rmi://" + hostname + ":" + port
+ "/RMIInterface";
Naming.rebind(registration, Service);
System.out.println("Server is running");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}