Skip to Main Content

Java APIs

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!

Trying to understand java.net.InetAddress.isReachable() method

843790Feb 3 2007 — edited Mar 13 2007
Hey guys,

I'm just testing some of the Java 6 API classes. So I'm playing with the isReachable() method.

I keep getting a syntax error when I try to use the method.

Let me show you what I'm trying to do:

------------------------------------------------------
import java.net.*;
import java.util.Scanner;

class NetTest {

public static void main(String[] args) {
Scanner netScan = new Scanner(System.in);
String myNet = netScan.next();

try {
InetAddress myAddr = InetAddress.getByName(myNet).isReachable(null, 0, 100);
}
catch (java.net.UnknownHostException exc) {
System.out.println("Can't find the host");
}

}

----------------------------------------------

I get the syntax error for the line with .isReachable saying:

"Type mismatch: cannot convert from boolean to InetAddress"

The rest works, just not the .isReachable. I've looked at the usage of the method in the API, and I guess I'm Just not getting it or something. Can somebody help? Much appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2007
Added on Feb 3 2007
14 comments
903 views