• 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

rmiregistry and server

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could anyone tell me if i can start the server without run rmiregistry first?

i wanna start the server with "localhost" "port"
but if I rum "rmiregistry 1024", i could only assign the "port" 1024, or I can not start the server
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use LocateRegistry.createRegistry(int port) method.

For instance, this codes creates a new RMIRegistry, and registers a Server object with it:



To shut down the RMI registry, I unexport the registry object.


I hope this helps!
 
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can export multiple remote objects in the same port.

Regards
 
Zhaozhe Ruan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried your way, but when I try to connect from client to server, connection was refused, could you give me some suggestions?

thanks
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Zhaozhe,

In answer to your original question, if I understand correctly, what you want to do is start the RMI registry using a user-defined port number?

If this is the case I would recommend displaying a GUI to the user (created and displayed by an object i.e. ApplicationRunner.java with a main method that is not the server and does not require RMI to be running) and then ask for the appropriate information (url, port), and only then do you need to start the registry and instantiate your server object using the GUI object.

Best wishes,

Daniel
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Zhaozhe, comrade.

The answer to your last question is fairly evident. If you create the RMIRegistry and bind your objects and you simply let your program finish then your server dies.

You have to make sure your application will not die until you want so.
For instance (this is just for an example), put System.read() at the end of your server initilization code, so that your server dies until you press enter.




Evidently you will have to provide some way to the end user to shut down the server when he wants.

This will require a shutdown strategy in order that any pendant transaction is completed before the server dies, and no further transactions should be accepted while the server is shutting down.

I hope this helps!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic