Results 1 to 2 of 2
- 10-16-2009, 07:12 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
InetAddress.getLocalHost() issue...
Hello,
I am using Netbeans 6.7.1 on Fedora 11(Linux). The issue is that when I use InetAddress.getLocalHost() method, I get only the loopback interface IP. In Windows 7, I did same and got the IP that I was having. Right now in spite of being connected to the net and havinga live IP, I can't get that IP using the above mentioned method. Am I doing something wrong?
Thanks.
- 10-18-2009, 02:22 AM #2
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
There have been some reported issues with InetAddress.getLocalHost() in the past. If it's causing you trouble, you could try explicitly enumerating the interfaces:
N.B. Neither InetAddress.getLocalHost() or NetworkInterface will provide the local IP if the security policy you're running with doesn't allow it. This usually applies to Applets.Java Code:Enumeration<NetworkInterface> infs = NetworkInterface.getNetworkInterfaces(); while (infs.hasMoreElements()) { NetworkInterface inf = infs.nextElement(); System.out.println("Name : " + inf.getName()); Enumeration<InetAddress> addrs = inf.getInetAddresses(); while (addrs.hasMoreElements()) { System.out.println(" " + addrs.nextElement().getHostAddress()); } }Neil Coffey
Javamex - Java tutorials and performance info
Similar Threads
-
PDF Box issue
By jazz2k8 in forum Advanced JavaReplies: 0Last Post: 03-20-2009, 11:04 AM -
Session issue
By jazz2k8 in forum Advanced JavaReplies: 3Last Post: 11-23-2008, 02:07 AM -
convert InetAddress to a string
By hunterbdb in forum New To JavaReplies: 4Last Post: 10-18-2008, 09:50 AM -
Issue
By chaitu444 in forum New To JavaReplies: 2Last Post: 11-06-2007, 07:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks