<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>remote &#8211; Blackbams Blog</title>
	<atom:link href="https://blog.blackbam.at/de/tag/remote/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.blackbam.at/de</link>
	<description>development - digital arts - internet</description>
	<lastBuildDate>Wed, 23 Jan 2013 08:38:47 +0000</lastBuildDate>
	<language>de-DE</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.4</generator>
	<item>
		<title>Java RMI five Minutes tutorial</title>
		<link>https://blog.blackbam.at/de/2013/01/23/java-rmi-5-minutes-tutorial/</link>
					<comments>https://blog.blackbam.at/de/2013/01/23/java-rmi-5-minutes-tutorial/#respond</comments>
		
		<dc:creator><![CDATA[Blackbam]]></dc:creator>
		<pubDate>Wed, 23 Jan 2013 08:38:47 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[rmi]]></category>
		<category><![CDATA[Tutorial]]></category>
		<guid isPermaLink="false">https://blog.blackbam.at/?p=2030</guid>

					<description><![CDATA[This ultra short tutorial is just a summary of how Java RMI (remote method invocation) works. For explanation please check one of the other tutorials which you will find easily easily your favorite search engine. 1. Write RMI-Server Interface extends package java.rmi.Remote provide all methods to be called remotely each methods must through a remote [&#8230;]]]></description>
										<content:encoded><![CDATA[This ultra short tutorial is just a summary of how Java RMI (remote method invocation) works. For explanation please check one of the other tutorials which you will find easily easily your favorite search engine.
<h2>1. Write RMI-Server Interface</h2>
<ul>
	<li>extends package java.rmi.Remote</li>
	<li>provide all methods to be called remotely</li>
	<li>each methods must through a remote exception</li>
</ul>

<pre lang="java">
import java.rmi.*;
 
public interface ServerInterface extends Remote {
     public void method1() throws RemoteException;
     public int method2() throws RemoteException;
     // ...
}</pre>
<h2>2. Write Server Class</h2>
<ul>
	<li>implements RMI-Server Interface</li>
	<li>extends UnicastRemoteObject (at least for simple RMI)</li>
	<li>Constructor throws java.rmi.RemoteException</li>
	<li>must be registered at local registry</li>
</ul>
&nbsp;
<pre lang="java"> 
import java.rmi.*;
import java.net.MalformedURLExcpetion;
import java.rmi.registry.*;
import java.rmi.server.UnicastRemoteObject;
 
public class MyServer extends UnicastRemoteObject implements ServerInterface {
 
  MyServer() throws RemoteException {
    super();
  }
 
  public static void main(String[] args) {

    try {
      LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
    } catch (RemoteException ex) {
      System.out.println(ex.getMessage());
    }
    try {
      Naming.rebind("MyServer", new MyServer());
    } catch (MalformedURLException ex) {
      System.out.println(ex.getMessage());
    }
    catch (RemoteException ex) {
      System.out.println(ex.getMessage());
    }
  }
  // ...
}</pre>
<h2>3. Write a client</h2>
<ul>
	<li>get remote reference</li>
	<li>call remote methods</li>
	<li>be careful with rmi-specific problems (a more detailed tutorial will explain to you)</li>
</ul>
&nbsp;
<pre lang="java">// any class, ...
// url expects String in url format (e.g. http://127.0.0.1/MyServer for local testing)
 
try {
      ServerInterface server = (ServerInterface) Naming.lookup(url);
      server.method1();
      int calculated_by_server = server.method2();
      // ...
} catch (Exception ex) {

}</pre>
&nbsp;

<strong>API reference:</strong>
<ul>
	<li>RMI: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/Remote.html" rel="nofollow">Remote API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/server/UnicastRemoteObject.html" rel="nofollow">UnicastRemoteObject API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/registry/Registry.html" rel="nofollow">Registry API</a>, <a href="http://java.sun.com/javase/6/docs/api/index.html?java/rmi/registry/LocateRegistry.html" rel="nofollow">LocateRegistry API</a></li>
	<li>Properties: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/util/Properties.html" rel="nofollow">Properties API</a></li>
	<li>IO: <a href="http://java.sun.com/javase/6/docs/api/index.html?java/io/package-summary.html" rel="nofollow">IO Package API</a></li>
</ul>
&nbsp;

<strong>Further reading:</strong>
<a href="http://docs.oracle.com/javase/tutorial/rmi/index.html">http://docs.oracle.com/javase/tutorial/rmi/index.html</a><p><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fblog.blackbam.at%2Fde%2F2013%2F01%2F23%2Fjava-rmi-5-minutes-tutorial%2F&#038;title=Java%20RMI%20five%20Minutes%20tutorial" data-a2a-url="https://blog.blackbam.at/de/2013/01/23/java-rmi-5-minutes-tutorial/" data-a2a-title="Java RMI five Minutes tutorial"><img class="colorbox-2030"  src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.blackbam.at/de/2013/01/23/java-rmi-5-minutes-tutorial/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
