Ping with Runtime

Posted on 2005-04-20
Last Modified: 2006-11-18
Why does this work Runtime.exec("ping"), but Runtime.exec("ping -n 1") throws the attached exception?  If -n is a valid argument for ping on a windows platform?  I did verify that ping -n works from within DOS. CreateProcess: "ping -n" error=2
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(
        at java.lang.ProcessImpl.start(
        at java.lang.ProcessBuilder.start(
        at java.lang.Runtime.exec(
        at java.lang.Runtime.exec(
        at PingTest.PingTest(
        at ThreadNetworkScan.ipCheck(

Question by:jhughes4
    LVL 86

    Accepted Solution


    Runtime.exec(new String[] { "ping", "-n", "1", "" });
    LVL 86

    Expert Comment


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now