tags:

views:

1653

answers:

3

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

A: 

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

Andreas_D
+1  A: 

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.)

Bill the Lizard
A: 

http://java.sun.com/j2se/1.4.2/docs/guide/rmi/javarmiproperties.html:

java.rmi.activation.port (1.2 and later) This property is used to set the TCP port number on which this VM should communicate with rmid (by default, rmid listens on port 1098, but can be set to listen on a different port by using the -port option on the rmid command line). The default value of this property is 1098, so this property only needs to be set on VMs that need to communicate with an instance of rmid that is running on a port other than 1098.

dfa