Prints the local hostname as Java would resolve it on Linux.
This program simulates how the local hostname is resolved in the OpenJDK Java 8 runtime, as outlined below.
- resolve local hostname with gethostname(2)
- resolve ip address belonging to the hostname you got in step 1 with getaddrinfo(3)
- resolve canonical hostname for the ip address with getnameinfo(3)
- generate build scripts (used autoconf 2.69)
$ autoreconf --install
- configure and build
$ ./configure
$ make
- run program
$ src/javahostname
man 2 gethostname
man 3 getaddrinfo
man 3 getnameinfo