7

How can I change the default RMI port (1099). It could be as JVM parameter or via coding, it doesn´t matter. Thanks.

3
  • Here is a solution via coding. Looks like you have to create a custom Registry on your selected port. Edit - just re-read your question: this will not change the default port but add a new registry to the existing one at Port 1099 Jun 2, 2009 at 12:06
  • 2
    1099 is the RMI registry server port, not the RMI server port. Jun 2, 2009 at 12:13
  • @VincentRobert It can be both.
    – user207421
    Apr 25, 2013 at 22:11

2 Answers 2

11

You can specify it on the command line. From the RMI Tutorial:

By default, the registry runs on port 1099. To start the registry on a different port, specify the port number on the command line. Do not forget to unset your CLASSPATH environment variable.

Microsoft Windows:

start rmiregistry 2001

Solaris OS or Linux:

rmiregistry 2001 &

In your code you use the LocateRegistry.getRegistry(String host, int port) override to locate the registry by hostname and port, as explained in the Creating a Client Program section of the tutorial. (The same applies when implementing your server.)

5
  • Ok, so what your saying is that there is no way to change the rmiRegistry port but you can change the rmiServer port from 1098 to whatever using a -D property arg to the JVM?
    – djangofan
    Mar 18, 2011 at 21:32
  • @djangofan: Not exactly. You change the rmiregistry port at the command line (as shown above). Mar 18, 2011 at 21:53
  • @djangofan he is saying exactly the opposite of that.
    – user207421
    Jul 10, 2011 at 4:56
  • ok, so in other words, there is no way to change the rmiRegistry port except by the method of starting "rmiregistry.exe" from the command line before starting the JVM?
    – djangofan
    Jul 11, 2011 at 19:54
  • @djangofan You are not reading attentively enough. He didn't say that either, and there is: you can start it in your JVM on any port you like via Locatearegistry.createaRgistry().
    – user207421
    Jul 25, 2012 at 5:55
3

You can specify your own port when exporting your remote object, either via super(port, ...) or exportObject(remote, port, ...) depending on whether you do or don't extend UnicastRemoteObject. If you extend Activatable there are similarly super() overloads with a port number. You can specify the Registry's port on the command line if you use that, otherwise via LocateRegistry.createRegistry() if you use that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.