sampleserverimpl.java
来自「java rmi例子」· Java 代码 · 共 51 行
JAVA
51 行
//-----------------------------------------------------------// File: SampleServerImpl.java//-----------------------------------------------------------import java.rmi.*;import java.rmi.server.*;import java.rmi.registry.*;public class SampleServerImpl extends UnicastRemoteObject implements SampleServer{ SampleServerImpl() throws RemoteException { super(); } public int sum(int a,int b) throws RemoteException { return a + b; } public static void main(String args[]) { //set the security manager try { System.setSecurityManager(new RMISecurityManager()); //create a local instance of the object SampleServerImpl Server = new SampleServerImpl(); //put the local instance in the registry Naming.rebind("SAMPLE-SERVER" , Server); System.out.println("Server waiting....."); } catch (java.net.MalformedURLException me) { System.out.println("Malformed URL: " + me.toString()); } catch (RemoteException re) { System.out.println("Remote exception: " + re.toString()); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?