my dog learned polymorphism*
The moose likes Distributed Java and the fly likes Starting the RMI server on Windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Starting the RMI server on Windows" Watch "Starting the RMI server on Windows" New topic
Author

Starting the RMI server on Windows

Mikael Månsson
Greenhorn

Joined: Sep 20, 2009
Posts: 17
Hi

I am just trying to use the three files in suns tutorial: http://java.sun.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html

Hello.java - a remote interface
Server.java - a remote object implementation that implements the remote interface
Client.java - a simple client that invokes a method of the remote interface

I have started the rmiregistry by running "start rmiregistry" in the java bin directory. There is no output in this window, i hope this is correct.

But when I try to run the server I get the following message:



I'm suspecting it having to do with the codebase parameter that I have omitted. But even if I try to add it I can't seem to figure out a way for it to start.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Mikael Månsson wrote:I have started the rmiregistry by running "start rmiregistry" in the java bin directory. There is no output in this window, i hope this is correct.

Yes.

And regarding your exception, how did you try to run the server program (i.e: what command) ? How is your class files are organized?

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Mikael Månsson
Greenhorn

Joined: Sep 20, 2009
Posts: 17
They are all located in the same default package.

Considering this, what would be the correct way to run the server?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

I'm suspecting it having to do with the codebase parameter that I have omitted. But even if I try to add it I can't seem to figure out a way for it to start.

Mikael Månsson wrote:They are all located in the same default package. Considering this, what would be the correct way to run the server?

You should add the codebase when running the server. As the tutorial says just put the absolute path to the directory where your classes are located (this case as you are using default package). It should work.
Mikael Månsson
Greenhorn

Joined: Sep 20, 2009
Posts: 17
Ok, but for the submission to the SCJP, where you deliver a jar file, what is then the preferred way?

Lets say I have the following structure:



Say that the remote object and server is in remote and the rmi client is in local. I will use the same jar on both machines but with different startup options. How do i specify the codebase when I start the application? Can it be omitted, since the class files are available locally anyway?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Yes, you can specify a URL of a JAR in a codebase where classes are organized in correct package hierarchy. And if you are using same JAR in both server & client side then you don't need RMI.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Starting the RMI server on Windows