????Java?????????????Java RMI??Java Remote Method Invocation????Java???????????????????????????????ó???????????????????????е????????????????????????????????????????Java??????????????繃???з????????RMI???????????????????????????á?
???????????RMI?????4??????
????1???????????????????y???е????????????????????????????RemoteException????
????2????????????y?????
????3????????????????????2?ж??????
????4???????????????????RMI???á?
???????????????????
????1.????????????????????????????????Serializable????????????????
1 import java.io.Serializable;
3 public class Student implements Serializable {
5   private String name;
7   private int age;
9   public String getName() {
11       return name;
13   }
15   public void setName(String name) {
17       this.name = name;
19   }
21   public int getAge() {
23       return age;
25   }
27   public void setAge(int age) {
29       this.age = age;
31   }
33 }
????2.???????????????????????Remote???????????е????????????RemoteException????
????1 import java.rmi.Remote;
????3 import java.rmi.RemoteException;
????5 import java.util.List;
????6 public interface StudentService extends Remote {
????12   List<Student> getList() throws RemoteException;
????14 }
????3.?????????????????2?е??????????????UnicastRemoteObject??????д????ε????????
1 import java.rmi.RemoteException;
3 import java.rmi.server.UnicastRemoteObject;
5 import java.util.ArrayList;
7 import java.util.List;
11 public class StudentServiceImpl extends UnicastRemoteObject implements
13       StudentService {
15   public StudentServiceImpl() throws RemoteException {
17   }
21   public List<Student> getList() throws RemoteException {
23       List<Student> list=new ArrayList<Student>();
25       Student s1=new Student();
27       s1.setName("????");
29       s1.setAge(15);
31       Student s2=new Student();
33       s2.setName("????");
35       s2.setAge(20);
37       list.add(s1);
39       list.add(s2);
41       return list;
43   }
45 }