??Java????????
???????????? ???????[ 2013/3/28 10:12:37 ] ????????
??????????
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
/**
*
* MyRemoteImpl.java
*
* ?? ??? TODO
* ?? ???? MyRemoteImpl.java
*
* ver ????? ??? ?????? ???????
* ????????????????????????????????????????????????????????????????????????????????????????????
* V1.00 2013-3-19 ??? ?????? ????
*
* Copyright (c) 2013 dennisit corporation All Rights Reserved.
*
* Email:<a href="mailto:DennisIT@163.com">???????</a>
*
* ????????????????????????????????й?????????м??????????UnicastRemoteObject
* (????java.rmi.server)???????????????Щ????
*
*/
public class MyRemoteImpl extends UnicastRemoteObject implements MyRemote{
/**
* ?????????????????????????????д?????????????????????????????????з??????????
*
* UnicastRemoteObject?и?С??????????????????RemoteException.????????????
* ???????????????????????????е????????????RemoteException.??????????????????
* ??????????????????????????????????????????????????????????????????????
* @throws RemoteException
*/
protected MyRemoteImpl() throws RemoteException {
}
/**
* ??????????е????????????????RemoteException
*/
@Override
public String sayHello(){
return "server says?? rmi hello world !";
}
public static void main(String[] args) {
try {
/**
* ???????????????????????????????????????????????????????????RMI Registry
* (????????????????????????????).???????????RMI?????stub???registry?У?
* ??????????????????.???java.rmi.Naming??rebind()????????
*/
MyRemote service = new MyRemoteImpl();
/**
* ?????????????????t????Naming.rebind()????????????????????????????????
*/
Naming.rebind("Remote Hello World"?? service);
} catch (Exception e) {
e.printStackTrace();
}
}
}
????????????
import java.rmi.Naming;
/**
*
* MyRemoteClient.java
*
* ?? ??? TODO
* ?? ???? MyRemoteClient.java
*
* ver ????? ??? ?????? ???????
* ????????????????????????????????????????????????????????????????????????????????????????????
* V1.00 2013-3-19 ??? ?????? ????
*
* Copyright (c) 2013 dennisit corporation All Rights Reserved.
*
* Email:<a href=mailto:DennisIT@163.com>???????</a>
*
*/
public class MyRemoteClient {
public void exec(){
try {
/**
* ???????????stub???????????????????????????.????RMI registry??.???????????綽
* ???????????????????????????????????.
* ???????RMIRegistry??????stub????
* Naming.lookup("rmi://127.0.0.1/Remote Hello World");
* ???????
* rmi://127.0.0.1/Remote Hello World
* 127.0.0.1????????????????IP???
* Remote Hello World??????????????????
*
*/
MyRemote service = (MyRemote)Naming.lookup("rmi://127.0.0.1/Remote Hello World");
String tmp = service.sayHello();
System.out.println(tmp);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new MyRemoteClient().exec();
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11