📄 startremoteobject.java
字号:
/*################################################################################# startRemoteObject.java## Copyright (C) 2007 Fernando G. Tinetti## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA################################################################################ * * startRemoteObject.java * Starts the remote object. More specifically: * 1) Creates the object which has the remote methods to be * invoked * 2) Registers the object so that it becomes avaliable * The specific object to be created and registered depends on * the line * remoteClassv<i> robject = new remoteClassv<i>(); * where <i> is the number (version) of the "server" implemented * Expects a local rmiregistry running and waiting on the * default registry port. * Used with * java startRemoteObject */import java.rmi.registry.LocateRegistry; /* createRegistry */import java.rmi.registry.Registry; /* REGISTRY_PORT */import java.rmi.Naming; /* re/bind */public class startRemoteObject{ public static void main (String args[]) { try{ /* Create ("start") the object which has the remote method */ remoteClassv7 robject = new remoteClassv7(); /* Register the object on the rmiregistry */ String rname = "//localhost:" + Registry.REGISTRY_PORT + "/remote"; Naming.rebind(rname, robject); } catch (Exception e) { System.out.println("Hey, an error occurred at Naming.rebind"); e.printStackTrace(); System.out.println(e.getMessage()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -