Name: nt126004 Date: 04/09/2002 FULL PRODUCT VERSION : java version "1.3.1" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24) Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode) FULL OPERATING SYSTEM VERSION : Slackware 8.0 ADDITIONAL OPERATING SYSTEMS : RedHat, likely all other linux systems A DESCRIPTION OF THE PROBLEM : Linux machines differentiate between the localhost (127.0.0.1) address, which is used to simulate a network connection, and the actual IP address of the machine. In almost all cases, the latter is more valuable for developing a program - if a developer wants to simulate a connection, he can hard code in an address of 127.0.0.1. However, he obviously cannot hard code the IP address for every computer that is to run the program. Also, one can't ask every user of one's program to edit their /etc/hosts file to run the program. That kind of requirement is enough to make developers look for another platform on which to run their programs. It would be much nicer behavior for Java to return the actual IP address of the machine on which it is run. 1. Bug ID : 4424859 Reg-test CheckInetAddress.java Failing java :classes_net, Reg-test CheckInetAddress.java Failing, State: Closed, fixed, Reported: Mar 12, 2001, Release reported against: ladybird http://developer.java.sun.com/developer/bugParade/bugs/4424859.html - Feb 12, 2002 2. Bug ID : 4460816 rmi connection error using linux server java :rmi, rmi connection error using linux server, State : Closed, not reproducible, Reported: May 18, 2001, Release reported against: 1.3 ^C - Feb 12, 2002 3. Bug ID : 4435662 InetAddress.getLocalHost() gives 127.0.0.1 under RedHat with DHCP STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. See bug reports 4435662 4424859 4460816 2. Note that this is rather important networking behavior that affects all linux systems, and it would be really cool to have Java be truly platform-independent. 3. EXPECTED VERSUS ACTUAL BEHAVIOR : Expected results of getLocalHost: return IP address of machine Actual results : return 127.0.0.1 This bug can be reproduced always. ----------------- BEGIN SOURCE -------------------- import java.net.*; public class LocalHostTest { public static void main(String[] args) { try { System.out.println(InetAddress.getLocalHost()); } catch (Exception e) { e.printStackTrace(); } } } (Review ID: 144338) ======================================================================
|