This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rmic unnecessary for SCJD project?

 
Dan Jones
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am an RMI newbie and am testing out the ComputeEngine example in the RMI trail of Sun�s Java Tutorial. I have made several modifications to the example code in conformance with the following SCJD project guidelines:

� You must not require the use of an HTTP server.
� You must not require the installation of a security manager.
� You must provide all classes pre-installed so that no dynamic class downloading occurs.
� You must use RMI over JRMP (do not use IIOP).

I compiled the whole application using javac only (no rmic) and copied the resulting directory structure to another computer on the same network.

At this point, I did not expect the application to work propery because I had not run rmic. I decided to try it out to see what sort of errors might occur. I first tried to start the client on machine A and got a java.net.ConnectException: Connection refused. I figured that�s expected given that the server had not been started.

I then started the server on machine B. It ran without error even though I had not run rmic. I checked netstat and saw that it was listening on the port I specified.

After starting the server on machine B, I went back to machine A and ran the client again� it ran the application with expected output!

Why is my program running as an RMI application without ever compiling it using rmic? I am guessing that stubs are unnecessary as long as all of the classes are available on both client and server to prevent dynamic loading. However, it seems that many posters on this forum are using rmic despite the explicit project requirement to avoid dynamic loading. Are they taking extra steps or am I missing something? I am worried that my configuration is a special case and a similar build might flop for the exam graders�

Thanks in advance!
[ April 01, 2005: Message edited by: Dan Jones ]
 
Wei-ju Wu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you use Java 5 ? Since that version, rmic is not longer needed to be invoked explicitly, the stubs will be generated on the fly.
 
Dan Jones
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! I do use Java 5 and have found the official release from Sun:
http://java.sun.com/j2se/1.5.0/docs/guide/rmi/relnotes.html

The first sentence tells most of the story:

�This release adds support for the dynamic generation of stub classes at runtime, obviating the need to use the Java(tm) Remote Method Invocation (Java RMI) stub compiler, rmic, to pregenerate stub classes for remote objects.�

Now if only they would update the Java Tutorial... Has anyone seen any good, up-to-date RMI tutorials with examples on properly coding solutions that don�t make use of dynamic downloading?
[ April 04, 2005: Message edited by: Dan Jones ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic