⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sampleserverimpl.java

📁 java rmi例子
💻 JAVA
字号:
//-----------------------------------------------------------// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -