liquid
09-10-2002, 05:25 PM
Hi. I am having problems getting this to work.
import java.net.*;
public class GetIP {
public static void main(String[] args) {
if ( (args.length == 0) || (args.length > 1) ) {
System.out.println("Usage: java GetIP <hostname> ");
System.exit(0);
}
String host = args[0];
try {
InetAddress inet = InetAddress.getByName("host");
}
catch(Exception e) {
System.out.println("Error");
System.exit(0);
}
System.out.println("IP : " + inet.GetHostAddress());
}
}
i want it to take the hostname from the commandline and return the IP.
The error I get is:
GetIP.java:19: cannot resolve symbol
symbol : variable inet
location: class GetIP
System.out.println("IP : " + inet.GetHostAddress());
1 error
import java.net.*;
public class GetIP {
public static void main(String[] args) {
if ( (args.length == 0) || (args.length > 1) ) {
System.out.println("Usage: java GetIP <hostname> ");
System.exit(0);
}
String host = args[0];
try {
InetAddress inet = InetAddress.getByName("host");
}
catch(Exception e) {
System.out.println("Error");
System.exit(0);
}
System.out.println("IP : " + inet.GetHostAddress());
}
}
i want it to take the hostname from the commandline and return the IP.
The error I get is:
GetIP.java:19: cannot resolve symbol
symbol : variable inet
location: class GetIP
System.out.println("IP : " + inet.GetHostAddress());
1 error