Reputation: 816
In my program, the user can open a web page using his default browser. But what I possess is the IP address of the machine and not its URL
.
I found out that a web page can be easly opened with:
java.awt.Desktop.getDesktop().browse(uri);
but browse
accept URI
object. Even a conversion URL-IP address is not a solution because I don't know what machine's URI is, I've only its IP-Address. So, is there a way to open a web page passing its IP address? Thank you a lot!
Upvotes: 0
Views: 1134
Reputation: 8278
If the IP is publically accessible (the host is not behind the NAT) you can replace the host name by the IP address in the URI.
One possible thing that can mess it up is that in your client machine in etc/hosts
file the hostname is mapped to some other IP address.
You might want to check this question to better understand how hostname to IP resolution works.
Upvotes: 1