RMI is the Java Platform for remote invocation of the specification, here is a small example, the native test through
A total of three Java classes, remote interfaces, server-side programs, client programs
Remote interface:
import java.rmi.*;
public interface HelloIn extends java.rmi.Remote{
String sayHello() throws RemoteException;
}
Service-Side programs:
/**
* author by http://www.bt285.cn http://www.5a520.cn
*/
import java.rmi.*;
import java.net.*;
import java.rmi.registry.*;
import java.rmi.server.*;
public class Hello extends java.rmi.server.UnicastRemoteObject implements HelloIn{
public Hello() throws RemoteException{
super();
}
public String sayHello() throws RemoteException{
return "Hello,World!";
}
public static void main(String[] args){
//System.setSecurityManager(new java.rmi.RMISecurityManager());
try{
Hello h=new Hello();
java.rmi.Naming.rebind("hello",h);
System.out.print("Ready......");
}
catch(Exception e){
e.printStackTrace();
}
}
}