Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Draft saved
Draft discarded
Cancel
13
  • Do you have a security manager running? From the documentation of getLocalHost(): "If the operation is not allowed, an InetAddress representing the loopback address is returned." You may also try using getCanonicalHostName() to get an fqn rather than getHostName() Commented Jan 18, 2018 at 16:23
  • You mean security manager for Java 8? I mean if there were some kind of Linux security manager it wouldn't permit the operation you're talking about regardless of Java version, right? Commented Jan 18, 2018 at 16:40
  • I suppose, the documentation specifically referred to Java-side security managers, but of course, operating system side restrictions affect the outcome too. But it’s not clear whether the Java API can guaranty a particular behavior for that case... Commented Jan 18, 2018 at 16:44
  • I ask because it probably wouldn't be the operating system otherwise my previous calls with pre-Java 8 wouldn't have worked. Do you know where I'd like for Java-side security managers? Commented Jan 18, 2018 at 17:09
  • 1
    @Holger well, I see comments in our code that actually do exec(hostname)... and they state that on Amazon InetAddress.getLocalHost() returns (sometimes) the loopback device, which is localhost. I might need to ping the author of these lines to understand what is going on actually Commented Jan 19, 2018 at 9:16

lang-java

AltStyle によって変換されたページ (->オリジナル) /