Previously, when I was using openJDK 10, the below code gave my local IP address, however now it (inetAddress.getHostAddress()
) always returns 127.0.1.1
import java.net.*;
class main {
public static void main(String[] args) throws Exception {
InetAddress inetAddress = InetAddress.getLocalHost();
System.out.println("IP Address:- " + inetAddress.getHostAddress());
}
}
Additional information:
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu219.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu219.04.1, mixed mode, sharing)
I recently moved to ubuntu 19.04 from (18.04 LTS which had openJDK 10) [Not a virtual Machine],Is this due to firewall? In that case, how do I allow java through the firewall.