• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Learning RMI for SCJD

 
Ranch Hand
Posts: 92
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
John McParland
Ranch Hand
Posts: 92
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 92
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic