Content deleted Content added
m Disambiguating links to External (link removed) using DisamAssist. |
→Example: ; : fix syntaxhighlight error |
||
Line 16:
==Jini version==
[[Jini]] offers a more advanced version of RMI in Java. It functions similarly but provides more advanced security, object discovery capabilities, and other mechanisms for distributed object applications.<ref name="From P2P to Web Services and Grids 2005">{{cite book |first=Ian J |last=Taylor |title=From P2P to Web Services and Grids : Peers in a Client/Server World |series=Computer Communications and Networks |publisher=Springer-Verlag |___location=London |year=2005 |isbn=1852338695 |doi=10.1007/b138333 |url=https://archive.org/details/fromp2ptowebserv0000tayl |oclc=827073874 |url-access=registration }}{{page needed|date=September 2017}}</ref>
==Example==
The following classes implement a simple client-server program using RMI that displays a message.
<syntaxhighlight lang=java>
Line 31 ⟶ 32:
</syntaxhighlight>
<syntaxhighlight lang=java>
Line 71 ⟶ 72:
</syntaxhighlight>
<syntaxhighlight lang=java>
Line 86 ⟶ 87:
Before running this example, we need to make a 'stub' file for the interface we used. For this task we have the RMI compiler - 'rmic'
*Note: we make a stub file from the '*.class' file with the implementation of the remote interface, not from the '*.java' file.
rmic RmiServer
Note that since version 5.0 of J2SE support for dynamically generated stub files has been added, and rmic is only provided for backwards compatibility with earlier runtimes,<ref>{{cite web|title=Java RMI Release Notes|url=http://docs.oracle.com/javase/1.5.0/docs/guide/rmi/relnotes.html|publisher=Oracle|access-date=9 May 2012}}</ref> or for programs that don't provide an explicit port number (or zero) when exporting remote objects, which is required for generated stubs to be possible, as described in the Javadoc for UnicastRemoteObject. See the comment in the constructor above.
|