my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Learning RMI for SCJD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Learning RMI for SCJD" Watch "Learning RMI for SCJD" New topic
Author

Learning RMI for SCJD

John McParland
Ranch Hand

Joined: May 11, 2009
Posts: 92

Hi folks,

I've recently been learning about RMI (using http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html) in an effort to prepare me for the SCJD assignment. Now that I have my assignment I'm a bit worried I don't know it well at all. For example here are a few things I thought necessary to use RMI;

1) Use of an HTTP server or the ClassFileServer code distributed by SUN.
2) The need to specify command line properties such as java.rmi.codebase
3) The need for security managers.

All are not allowed in my assignment!

So I was wondering what others did to learn about RMI as clearly I have do not have enough knowledge to tackle the problem?

Passed: SCJP 6 (90%), SCJD 6
Other: Spring training, extensive Swing experience
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5539
    
  13

Hi John,

I simply used this tutorial as a starting point for RMI (and I didn't know anything about it before starting the SCJD assignment).

And about the do's and don'ts of your interfaces and classes I started a topic here. And also if you use the search engine on this forum you'll find a lot of topics about RMI which might be helpful.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
John McParland
Ranch Hand

Joined: May 11, 2009
Posts: 92

Hi Roel,

thanks for the exceptionally quick reply.

Yes I've tried that tutorial too and I think it is partly what has muddied the waters for me. It seems to want an HTTP server and extra command line parameters which I'm not allowed in my assignment.

Would I be right in thinking that since I should be generating stubs for my classes there is no need for an HTTP server / extra cmd line parameters / security manager?

Sorry I'm asking more questions...
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5539
    
  13

Hi John,

The SCJD forum is known for his exceptional quick replies

Regarding rmic, have a look at this thread.

Regarding to your other questions: no need to worry about these issues. The best to learn and get a grasp on things is, create a small sample application (something like this one or just use the one from the tutorial). And if you see something about securitymanager, just delete it (because it is not needed and for the assignment not allowed).


code to bind your object to rmi registry


code to retrieve a remote client

That should do it.
Good luck!

Kind regards,
Roel
John McParland
Ranch Hand

Joined: May 11, 2009
Posts: 92

Hi Roel,

I think you should write your own tutorials. Finally I managed to get a quick and dirty RMI example working and, more importantly, running on two different machines!

Would you (or anyone at all of course) mind having a look over this simple example and see if I'm doing the right thing. It's not part of my SCJD;

Hello.java


Server.java


Client.java


RunMe.java


Build instructions;

1. Place the above code in a directory called "hello".
2. Built with javac hello/*.java
3. Create the stub with rmic hello.Server
4. Create a Jar file as follows;
jar cvfe runme.jar hello.RunMe hello/*.class

Run instructions;
1. Move the runme.jar to some directory far away from "hello" (to ensure its not using the classes in the classpath).
2. Run the server with;
java -jar runme.jar Server <port> <serviceName>
e.g. java -jar runme.jar Server 2000 JohnService
3. Run the client with;
java -jar runme.jar Client <host> <port> <serviceName>
e.g. java -jar runme.jar Client localhost 2000 JohnService

You could even run the Server on another machine, so long as it is accessible from the one you run the client on and specify its hostname on the cmd line.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5539
    
  13

Hi John,

Finally I managed to get a quick and dirty RMI example working and, more importantly, running on two different machines!


Would you (or anyone at all of course) mind having a look over this simple example and see if I'm doing the right thing.
Seems ok to me. In my SCJD assignment I used the same code to run my server and client.

Kind regards,
Roel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Learning RMI for SCJD