Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:00:49+00:00 2026-06-14T23:00:49+00:00

I have a task to make a simple console pinger in Java. I tried

  • 0

I have a task to make a simple console pinger in Java.
I tried the following code and I have 2 main issues.

First of all even if I am connected to the internet (I can ping from console any site), when I run the code returns false.

Second, is it possible to track the time of response of the ping?

Here is the code:

try {
    InetAddress address = InetAddress.getByName(the_link);
    System.out.println(the_link);
    // Try to reach the specified address within the timeout
    // periode. If during this periode the address cannot be
    // reach then the method returns false.
    boolean reachable = address.isReachable(5000);
    System.out.println("Is host reachable? " + reachable);
} catch (Exception e) {
    e.printStackTrace();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:00:50+00:00Added an answer on June 14, 2026 at 11:00 pm

    This is not a good one to use for most external ips.
    Instead following can be used

    boolean reachable = (java.lang.Runtime.getRuntime().exec("ping -c 1 www.google.lk").waitFor()==0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have task to make simple app from three Views: in first: UITableView (it
I have just not been able to make even a simple Vimeo API call
I want to make an android simple application in which, I have one task
I have a task to make a survey to be displayed in SharePoint 2007
I am trying to do a simple task: I have an editable text field,
I have an Ant task to call a java process that takes a file
It's very simple task, but I struggle for hours. I have parse xml from
I want to make a very simple task in objective-c under IOS5 : convert
I have a simple task to display a fruit object based on certain conditions.
I have a simple rake task which consumes pretty much data via ActiveRecord. (contacts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.