blackneos940
Active Member
Hello everyone..... :3 As I sit here sipping Coffee, I'm trying to get this Java Program I got over at "https://stackoverflow.com/questions/3584210/preferred-java-way-to-ping-an-http-url-for-availability" to work..... First, here's the actual Code..... :3
As you can see, I made some changes to the actual Code (so it would Compile, or at least come close to doing so)..... Any help.....? :3 Does anyone know how to Program in Java.....? :3 FYI (if it matters), I have Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10) installed (this is what "java --version" reveals in Guake)..... :3 Anywho, thanks for any help guys..... :3 I REALLY appreciate it..... :3
EDIT: When I type "javac Ping_Website.java", it outputs:
Anywho, on to you, fellow Penguinites!!..... :3
Code:
import java.io.*;
import java.net.Socket;
public class Ping_Website
{
public static boolean ping_host(String host, int port, int timeout)
{
try(Socket socket = new Socket())
{
socket.connect(new InetSocketAddress(host, port), timeout);
return true;
}
catch(IOException e)
{
return false; //Either a Timeout or unreachable or failed DNS lookup
}
}
}
As you can see, I made some changes to the actual Code (so it would Compile, or at least come close to doing so)..... Any help.....? :3 Does anyone know how to Program in Java.....? :3 FYI (if it matters), I have Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10) installed (this is what "java --version" reveals in Guake)..... :3 Anywho, thanks for any help guys..... :3 I REALLY appreciate it..... :3
EDIT: When I type "javac Ping_Website.java", it outputs:
Code:
Ping_Website.java:14: error: cannot find symbol
socket.connect(new InetSocketAddress(host, port), timeout);
^
symbol: class InetSocketAddress
location: class Ping_Website
1 error
Anywho, on to you, fellow Penguinites!!..... :3