I am trying to compile this:
public class DNSLookUp {
public static void main(String[] args) {
InetAddress hostAddress;
try {
hostAddress = InetAddress.getByName(args[0]);
System.out.println (hostAddress.getHostAddress());
}
catch (UnknownHostException uhe) {
System.err.println("Unknown host: " + args[0]);
}
}
}
I used javac dns.java, but I am getting a mess of errors:
dns.java:1: error: The public type DNSLookUp must be defined in its own file
public class DNSLookUp {
^^^^^^^^^
dns.java:3: error: InetAddress cannot be resolved to a type
InetAddress hostAddress;
^^^^^^^^^^^
dns.java:6: error: InetAddress cannot be resolved
hostAddress = InetAddress.getByName(args[0]);
^^^^^^^^^^^
dns.java:9: error: UnknownHostException cannot be resolved to a type
catch (UnknownHostException uhe) {
^^^^^^^^^^^^^^^^^^^^
4 problems (4 errors)
I have never compiled/done Java before. I only need this to test my other programs results. Any ideas? I am compiling on a Linux machine.