File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes rmic unnecessary for SCJD project? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "rmic unnecessary for SCJD project?" Watch "rmic unnecessary for SCJD project?" New topic

rmic unnecessary for SCJD project?

Dan Jones

Joined: Apr 01, 2005
Posts: 5
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 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

Joined: Feb 16, 2005
Posts: 147
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.

"The UrlyBird catches the certificate. And he's gonna FlyByNight"<br /> <br />SCJP 1.2/5.0, SCJD, SCBCD, SCWCD, SCEA
Dan Jones

Joined: Apr 01, 2005
Posts: 5
Thanks! I do use Java 5 and have found the official release from Sun:

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 ]
I agree. Here's the link:
subject: rmic unnecessary for SCJD project?
It's not a secret anymore!