Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

InetAddress Error

996701Mar 13 2013 — edited Mar 13 2013
I'm a newbie , and I've short program:
------------------------


import java.net.*;

public class timdcIP {
public static void main(String[] args){
try{
if(args.length!=1){
System.out.println("Searching IP Addresss: ");

}
InetAddress host= new InetAddress.setByName(args[0]);
String HostName=host.getHostName();
System.out.println("HostName : "+ HostName);
System.out.println("IP Address : "+ host.getHostAddress());
}catch(UnknownHostException e){
System.out.println("Can't search IP Address");
return;
}
}

}
------------

And the Error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
InetAddress.setByName cannot be resolved to a type

at timdcIP.main(timdcIP.java:10)


Please help me to fix this problem. Thank you very much!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2013
Added on Mar 13 2013
3 comments
1,012 views