13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

144Chapter 5The Sun Microsystems Java Software <str<strong>on</strong>g>Development</str<strong>on</strong>g> KitTo generate RMI stubs for our applicati<strong>on</strong>, run rmic 19 against the classthat implements the remote interface:penfold$ rmic net.multitool.RMIDemo.Sessi<strong>on</strong>ImplWhen you are writing “traditi<strong>on</strong>al” Java RMI, that is just about all youneed to know about rmic. The program actually has a large number of opti<strong>on</strong>sand switches, but most of these are to support alternate protocols and systems,such as CORBA IDL and IIOP. If you know what these are, and make use ofthese, you will find details <strong>on</strong> these opti<strong>on</strong>s in Sun’s rmic tool documentati<strong>on</strong>. 205.8.3 The rmiregistry ToolThe rmiregistry is a naming service that binds RMI server stubs to simplenames. Invoking it is incredibly simple. Just type rmiregistry. You may wantto run it <strong>on</strong> other than the default port (1099). For that, just specify the portnumber <strong>on</strong> the command line:$ rmiregistry 21099 &That example shows us running a registry <strong>on</strong> port 21099 and running itin the background. You might want to use a n<strong>on</strong>standard port in order to runa test versi<strong>on</strong> of the service while the producti<strong>on</strong> versi<strong>on</strong> remains available <strong>on</strong>the standard port.That is just about all there is to rmiregistry. You can find details in theSun Java SDK documentati<strong>on</strong>.5.8.4 Setting Up Servers and ClientsSo far, we have written an RMI interface, a server implementati<strong>on</strong>, and a clientimplementati<strong>on</strong>. We have generated RMI stubs for our RMI object. We are19. Be careful! If you have <strong>on</strong>e or more Java SDKs installed and you have the GNU Compilerfor Java installed, watch out for your PATH. The Java compiler and the Java runtime from theJDK d<strong>on</strong>’t collide with gcj because the compiler has a different name and gcj compiles to nativebinaries. But gcj does have an rmic compiler, and it is usually in /usr/bin, which is usuallyahead of your JDK in the executable path. If you run rmic and it explodes with errors, makesure you aren’t running the rmic from gcj against .class files from a JDK. (And, yes, this bitme and had me c<strong>on</strong>fused for a while!)20. http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/rmic.html

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!