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.

146Chapter 5The Sun Microsystems Java Software <str<strong>on</strong>g>Development</str<strong>on</strong>g> KitExample 5.13 A Java security policy file suitable for the RMI examplegrant {permissi<strong>on</strong> java.net.SocketPermissi<strong>on</strong> "*:1024-65535", "c<strong>on</strong>nect,accept";permissi<strong>on</strong> java.net.SocketPermissi<strong>on</strong> "*:80", "c<strong>on</strong>nect,accept";};5.8.4.2 Our Envir<strong>on</strong>mentWe have two machines. One, penfold, is our server machine. The other,grovel, is our client machine. To keep things straight in our samples, the shellprompts will have the host names in them.If you are using a JDK that supports the 1.2 RMI specificati<strong>on</strong> (and wehope you are—it’s in all current JDKs), you have to give your server and yourclient permissi<strong>on</strong> to access the network ports needed to run. By default, theJava runtime will look for a security policy file in the home directory of theuser running the VM. The default name of the file is .java.policy. Example5.13 shows what we suggest you put in this file, at least to run this example.NOTEYou will have to put this in your home directory both <strong>on</strong> the server and <strong>on</strong> allclient machines.5.8.4.3 Compiling and Running the ServerOur packages here follow Sun’s suggested naming c<strong>on</strong>venti<strong>on</strong> of yourdomain name, reversed, followed by your package names. It so happens thatMr. Schwarz’s domain is called multitool.net (named after his firstbook, Multitool <strong>Linux</strong>), so we put all of these classes in a package callednet.multitool.RMIDemo.For all of the examples in this secti<strong>on</strong>, as well as the following secti<strong>on</strong> <strong>on</strong>building and running the client, assume that our current working directory isthe directory that c<strong>on</strong>tains the net directory of our source code.The output you see in Example 5.14 includes the result of running ourclient <strong>on</strong>ce. Note that the Sessi<strong>on</strong>Impl class doesn’t terminate. It keepsrunning to service clients indefinitely.

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

Saved successfully!

Ooh no, something went wrong!