I assumed that if I set -Djava.rmi.server.hostname = localhost, it should only listen to 127.0.0.1
Not.
I do not understand what java.rmi.server.hostname manages?
Yes. java.rmi.server.hostname has nothing to do with what IP address the remote object is listening on. This is determined by RMIServerSocketFactory.
To correct the wrong quote from my book in another answer (subsequently deleted):
java.rmi.server.hostname: hostname string; the default value is the local host IP address in dotted-quad format ... which is built into the remote stubs created by this JVM when the deleted objects are exported. This can be used to manage the effective IP address of RMI servers exported by multi-homed hosts. This property is read exactly once in the life of the JVM. [one]
To expand it, it can also be used to manage the effective IP address (as seen by clients) of RMI servers exported by hosts that are located behind NAT devices. This does not necessarily have anything to do with the local host, for example. in NAT situations, and it can either be a host name, or a dotted IPv4 address, or an IPv6 address.
[1] Pitt and McNiff, java.rmi, Remote Method Call Guide, Addison Wesley 2001, p.258.
Ejp
source share