You must configure the firewall to allow for the JVM (java.exe
) to open connections. The java code does not need to change, it is a configuration issue.
how to use InetAddress in Windows host with firewall
-
10-12-2021 - |
Question
I want to get an example or suggestion of how to use InetAddress in windows systems with firewall active. I don't know what is blocked by the firewall that isn't allowing this class in windows to work.
When I try to use this code in windows with firewall disabled I get the host name and isReachable
to true:
InetAddress addrs = null;
try {
addrs = InetAddress.getByName("192.168.1.1");
System.out.println(addrs.getHostName());
System.out.println(addrs.isReachable(100));
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But activating firewall I get false
, I can use policy for this?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow