Java Ping

I am trying to write a simple Java ping utility. I found some example code on the internet butcan't seem to get it to work. Anyone have any suggestions....
import java.io.*;
import java.net.*;
public class PingTest {
public static void main(String[] args) throws Exception {
String address = "www.yahoo.com";
final int port = 7;
Socket so = new Socket(address, port);
BufferedReader br = new BufferedReader(new InputStreamReader( so.getInputStream() ) );
String timestamp = br.readLine();
System.out.println( address + " is alive at " + timestamp );
} // main method
} // class Ping

"ping" requires ICMP, which you can't get at directly from Java. However, if you're using 1.5, you can use the InetAddress.isReachable() API.
The code you've posted is trying to talk to the "echo" server (Port 7), as kind of a "poor man's ping". That'll work if the destination is running echod - which Y! appears NOT to be doing.
Of course, "ping www.yahoo.com" doesn't work either - they're probably blocking ICMP to filter out some standard DDoS attacks.
Grant

Similar Messages

  • Java Pinging question

    Hi
    First if all, I hope this is the correct place to post such question..My apologies if that is the case.
    Anyway, like a lot of other people, I'm trying to implement a Ping mechanism in Java. I have read some of the available suggestions and none really solves the problem.
    One idea is to use JNI...this is against what I am trying to achieve as I want to implement a pure java ping.
    Which means, I don't want to use a Native call such as Runtime.exec("cmd") neither;
    Thus, I have tried the following, to use a sock connection to get ping that way:
    public static long getPing(String url, int port, int timeout) throws IOException{
              long start, end;
              long pingTime = 0;          
              SocketAddress sockaddr = new InetSocketAddress(url, port);          
              Socket socket = new Socket();
              start = System.currentTimeMillis();
              socket.connect(sockaddr);
              end = System.currentTimeMillis();
              socket.close();
                    pingTime = end - start;
              return pingTime;
         }My quesiton is, even though this implementation seems to work, it does not provide a good solution as opening a socket is different from sending a icmp packet and thus doesn't really qualify as a ping. Is there a better approach to this problem?
    I know Java is not low level enough to deal with such things, is there no way around it?
    I hope have have explained myself here. I would be greatful for any ideas, or suggestions. It is a bit frustrating, as I have been scratching my head for the whole day trying to get this little thing solved.
    Thanks you for your time,
    Bigboy A

    Sjasja,
    Thank you for your reply.
    I'm actually trying to implement a pure java webcrawler, as I'm learning about java networking at the moment. While the crawler is working fine..I also need to include more functionalities, for example while crawling the program could obtain statistics on quality of service of a particular site - possibly through ping time of a give domain. By quality of service, I want to include things such as the quality of the network between my machine and the host, for example the response time of a site (the ping), the success rate of udp packets etc, and possibly more..sort like a network diagnose function.
    HTH
    Thanks alot

  • How can use java emulate ping function?

    When I type ping xxx.x.xx.x,it would send a icmp package.
    If the remote mechine has no echo,it would wait too long.
    So Making a runtime process to invoke ping command directly is not efficient.
    My single aim is showing the remote mechine exiting or not on web page.
    Any idea appreciate

    Runtime.exec,I know,but it's too long to wait if the mechine has no echo.
    The checked machine is not the pc,but the "set top box".
    Assume there are no firewall to block any port and any protocol.
    It can telnet to the STB by No.25 port.
    But when I use socket connection,it has no response.
    It's very weird.
    I have successfully to check the PC by this way.
    Anyway,this way also wait too long,although I have set the time out value.It has no use.
    BTW,I have search the forums again, some one write native C to emualte icmp.I still not test it and hope it not use that complex way.
    package TEST;
    import java.net.*;
    import java.io.*;
    * Useful to know if you can connect to a computer
    * Port 13 is the date time port
    * Port 7 is the echo port
    * Port 23 is the Telnet service port
    * Port 25 is the E-Mail port
    public class PING {
        public static void main (String [] args) {
            if(args.length !=2){
                System.out.println("Usage: java ping ");
                System.exit(0);
            String computer = args[0];
            int dayTimePort = 13; //each computer uses this port for date and time
            dayTimePort = Integer.parseInt(args[1]);
            BufferedReader in = null;
            Socket socketComputer = null;
            try{
                System.out.println(computer + ":" + dayTimePort);
                socketComputer = new Socket(computer,dayTimePort);
                socketComputer.setSoTimeout(1000);
                in = new BufferedReader( new InputStreamReader( socketComputer.getInputStream() ) );
                String timeStamp = in.readLine();
                System.out.println( computer + " is alive at " + timeStamp );
            }catch (UnknownHostException e) {
                System.err.println( "Don't know about host: " + computer );
                System.exit( 1 );
            }catch (IOException e) {
                System.err.println( "Couldn't get I/O for " + "the connection to: " + computer + e.getMessage());
                System.exit( 1 );
        } // end main
    } // end class ping.java

  • Ping using java

    I used the followning program ping.java to ping a remote host.
    It needs the host name as argument.
    I tried using
    java ping xxx.xxx.xx.xxx
    but it always reports that the host is down, while it actually isnt.
    Any ideas as to why this may not be working?
    (xx.. is the ip address of the remote machine)
    import java.io.*;
    import java.net.*;
    public class ping {
    public final static int ECHO_PORT = 7;
    public static void main(String argv[]) {
    if (argv.length != 1) {
    System.out.println("Usage: java ping hostname");
    System.exit(0);
    if (alive(argv[0]))
    { System.out.println(argv[0] + " is alive");
    } else{
    System.out.println("No response from " + argv[0] +". Host is down or does not exist");
    public static boolean alive(String host)
    Socket pingSocket = null;
    try {
    pingSocket = new Socket(host, ECHO_PORT);
    } catch (UnknownHostException e) {
    System.err.println("UnknownHostException: " +e);
    } catch (IOException io) {
    System.out.println("IOException: " + io);
    if (pingSocket != null)
    {  try {
    pingSocket.close();
    } catch (IOException e)
    { System.err.println("IOException: " + e);
    return true;
    } else
    { return false;

    That is factually accurate, but I believe irrelevant,
    because one cannot accurately distinguish the two
    cases.yes, in both cases a IOException is thrown, and the obly difference i've found is the message ("connection timed out" or "connection refused"), don't know if this is accurate, guess not.
    anyway, i feel it is not a proper way to do this, go opening tcp connections. but is the only way i know...

  • UDP Ping

    Dear Sirs,
    As some of you may be aware, I have written an ICMP pinger using Java. For my report, I wish to add a small code example showing a UDP ping. Could someone either a) point me to a VERY SIMPLE example, or b) knock one up quickly for me. It doesn't have to compile or run, and is really just for cosmetic effect. I know this is a stupid request so please don't bother telling me how rediculous I am, if I don't get any responses i'll knock it on the head with no detrement to my mark (I'm a student by the way!)
    Thanks for any help,
    Windy

    Geez... I've never been attacked before :)
    Don't worry about it... I'm an new/old school hacker... I'm rude to get my point across. You should say you know how UDP ping works.. and that you just want a code example. Say exactly what you want... often you will get it...
    import java.net.*;
    import java.io.*;
    import java.util.Random;
    import timer.NanoTimer;
      class Example {
         void example() {
         Nanotimer timer = new NanoTimer();
          for (int i = 0; i < n; ++i) {
            someComputationThatYouAreMeasuring();
            long duration = timer.reset();
            System.out.println("Duration: " + duration);
            // To avoid contaminating timing with printing times,
            // you could call reset again here.
          long average = timer.getTimeSinceConstruction() / n;
          System.out.println("Average: " + average);
    public class SuperPing {
      /** Whether or not to use a TCP Socket */
      static boolean udp;
      static int messageSize;
      /** either "rt", "th", or "in" depending the type of test to execute.
          "round-trip", "throughput", or "interact"
      static String type;
      static String destination;
      Socket tcpSocket;
      DatagramSocket udpSocket;
      public SuperPing() {
        if(type.equals("rt")) {
          if(udp) {
            roundTripUDP();
          else {
            roundTripTCP();
          return;
        if(type.equals("th")) {
          if(udp) {
            throughputUDP();
          else {
            throughputTCP();
          return;
        if(type.equals("in")) {
          interactTCP();
      public void roundTripUDP() {
        try {
          NanoTimer timer = new NanoTimer();
          Random random = new Random();
          long[] times = new long[12];
          for(int i=0; i<12; i++) {
            udpSocket = new DatagramSocket(1337);
            //System.out.println("Connected rt udp");
            byte[] data = new byte[messageSize];
            random.nextBytes(data);
            // ready the sending packet
            DatagramPacket out = new DatagramPacket
              (data,
               data.length,
               InetAddress.getByName(destination),
               7);// echo port 7
            // ready the receiving objects
            byte[] dataGot = new byte[messageSize];
            DatagramPacket got = new DatagramPacket(dataGot, dataGot.length);
            timer.reset();
            udpSocket.send(out);
            udpSocket.receive(got); // blocks for input
            long duration = timer.reset();
            //System.out.println
            // ("RoundTrip time for "+messageSize+" bytes is "+duration+"ns");
            System.out.println(messageSize +" : "+duration);
            times[i] = duration;
            //System.out.println("Received data of size "+dataGot.length);
          long avg = 0l;
          for(int i=2; i<times.length; i++) {
            avg += times;
    System.out.println("Avg: "+(avg /= 10));
    catch(IOException e) {
    e.printStackTrace();
    public void roundTripTCP() {
    try {
    NanoTimer timer = new NanoTimer();
    Random random = new Random();
    long[] times = new long[12];
    for(int i=0; i<12; i++) {
    tcpSocket = new Socket(destination,7);
    //System.out.println("Connected rt tcp");
    byte[] data = new byte[messageSize];
    random.nextBytes(data);
    // get the output stream for sending
    OutputStream out = tcpSocket.getOutputStream();
    // get the input stream for receiving
    InputStream in = tcpSocket.getInputStream();
    // ready the receiving objects
    byte[] dataGot = new byte[messageSize];
    timer.reset();
    out.write(data);
    out.flush();
    in.read(dataGot); // blocks for input
    long duration = timer.reset();
    out.close();
    in.close();
    //System.out.println
    // ("RoundTrip time for "+messageSize+" bytes is "+duration+"ns");
    System.out.println(messageSize +" : "+duration);
    times[i] = duration;
    //System.out.println("Received data of size "+dataGot.length);
    long avg = 0l;
    for(int i=2; i<times.length; i++) {
    avg += times[i];
    System.out.println("Avg: "+(avg /= (times.length-2)));
    catch(IOException e) {
    e.printStackTrace();
    public void throughputUDP() {
    try {
    Random random = new Random();
    udpSocket = new DatagramSocket(1337);
    //System.out.println("Connected rt udp");
    byte[] data = new byte[messageSize];
    random.nextBytes(data);
    // ready the sending packet
    DatagramPacket out = new DatagramPacket
    (data,
    data.length,
    InetAddress.getByName(destination),
    7);// echo port 7
    // ready the receiving objects
    byte[] dataGot = new byte[messageSize];
    DatagramPacket got = new DatagramPacket(dataGot, dataGot.length);
    NanoTimer timer = new NanoTimer();
    timer.reset();
    udpSocket.send(out);
    udpSocket.receive(got); // blocks for input
    long duration = timer.reset();
    double dataPut = ( (double)duration / 2.0 ) / (1000000000.0);
    dataPut = (double)(messageSize*8) / dataPut;
    dataPut /= 1000000.0;
    //System.out.println
    // ("Throughput for "+messageSize+" bytes is "+dataPut+"Mbits");
    System.out.println(messageSize +" : "+dataPut);
    //System.out.println("Received data of size "+dataGot.length);
    catch(IOException e) {
    e.printStackTrace();
    public void throughputTCP() {
    try {
    Random random = new Random();
    tcpSocket = new Socket(destination,7);
    //System.out.println("Connected rt tcp");
    byte[] data = new byte[messageSize];
    random.nextBytes(data);
    // get the output stream for sending
    OutputStream out = tcpSocket.getOutputStream();
    // get the input stream for receiving
    InputStream in = tcpSocket.getInputStream();
    // ready the receiving objects
    byte[] dataGot = new byte[messageSize];
    NanoTimer timer = new NanoTimer();
    timer.reset();
    out.write(data);
    out.flush();
    in.read(dataGot); // blocks for input
    long duration = timer.reset();
    out.close();
    in.close();
    double dataPut = ( (double)duration / 2.0 ) / (1000000000.0);
    dataPut = (double)(messageSize*8) / dataPut;
    dataPut /= 1000000.0;
    //System.out.println
    // ("Throughput for "+messageSize+" bytes is "+dataPut+"Mbits");
    System.out.println(messageSize +" : "+dataPut);
    //System.out.println("Received data of size "+dataGot.length);
    catch(IOException e) {
    e.printStackTrace();
    public void interactTCP() {
    try {
    Random random = new Random();
    tcpSocket = new Socket(destination,1337);
    System.out.println("Connected interact tcp");
    if( 1024*1024 % messageSize != 0 ) {
    System.out.println("1024 not / by "+messageSize+" evenly");
    return;
    int numberOfMessages = 1024*1024 / messageSize;
    byte[][] data = new byte[numberOfMessages][messageSize];
    for(int i=0; i<data.length; i++) {
    random.nextBytes(data[i]);
    // get the output stream for sending
    OutputStream out = tcpSocket.getOutputStream();
    // get the input stream for receiving
    byte[] dataGot = new byte[1];
    InputStream in = tcpSocket.getInputStream();
    NanoTimer timer = new NanoTimer();
    timer.reset();
    for(int i=0; i<data.length; i++) {
    out.write(data[i]);
    in.read(dataGot);
    long duration = timer.reset();
    //System.out.println("completed sequence in "+duration+"ns");
    System.out.println(numberOfMessages+" : "+messageSize +" : "+duration);
    } catch(IOException e) {
    e.printStackTrace();
    public static void main(String[] args) {
    // no args defaults to UDP roundTrip with message size of 1 byte
    udp = true;
    type = "rt";
    messageSize = 1;
    boolean typeSet = false;
    boolean udpSet = false;
    boolean messageSizeSet = false;
    for( int i=0; i<args.length; i++) {
    if(args[i].equals("-rt")) {
    if(typeSet) { printUsage(); return; }
    typeSet = true;
    type = "rt";
    if(args[i].equals("-th")) {
    if(typeSet) { printUsage(); return; }
    typeSet = true;
    type = "th";
    if(args[i].equals("-in")) {
    if(typeSet) { printUsage(); return; }
    typeSet = true;
    type = "in";
    if(args[i].equals("-mes")) {
    if(messageSizeSet) { printUsage(); return; }
    messageSizeSet = true;
    String messageSizeAsString = args[++i];
    messageSize = Integer.parseInt(messageSizeAsString);
    if(args[i].equals("-udp")) {
    if(udpSet) { printUsage(); return; }
    udpSet = true;
    udp = true;
    if(args[i].equals("-tcp")) {
    if(udpSet) { printUsage(); return; }
    udpSet = true;
    udp = false;
    if(args[i].equals("-des")) {
    if(destination != null) { printUsage(); return; }
    String next = args[++i];
    if(next.startsWith("-")) { printUsage(); return; }
    destination = next;
    if(destination == null || destination.length() == 0) {
    System.out.println("Must supply a destination address.");
    printUsage();
    return;
    new SuperPing();
    static void printUsage() {
    System.out.println
    ("java Ping -des destination [-udp|-tcp][-rt|-th|-in][-mes size]");
    That code uses a nanosecond timer. You could implement one for whatever system you are running... if you are running solaris you can find that one here. http://gee.cs.oswego.edu/dl/csc445/ .. toward the bottom of the page.
    I think for UDP ping this requires an echo server with udp enabled for it. That would be a simple matter to code. The other things it tests besides round trip times are throughput, and the interaction between throughput and message size. You need this little server running for that.import java.net.*;
    import java.io.*;
    public class PServer {
    public static void main(String[] args) {
    try {
    ServerSocket ss = new ServerSocket(1337);
    for(;;) {
    Socket s = ss.accept();
    System.out.println("accepted");
    InputStream in = s.getInputStream();
    OutputStream out = s.getOutputStream();
    byte[] b = new byte[1024*1024];
    int readSoFar = 0;
    for(;;) {
    int read = in.read(b);
    if(read == -1) {
    System.out.println("read failed");
    System.exit(1);
    readSoFar += read;
    if(readSoFar >= 1024*1024) {
    break;
    out.write((byte)42);
    } catch(IOException e) {
    e.printStackTrace();
    Enjoy

  • How to enable ping service on java-stack only system

    I have installed SAP NetWeaver 7.0 - Java Trial on local host.
    How can you activate the ping service there?
    It should work under "http://localhost:50000/sap/bc/ping"
    (I know how to activate it with transaction SICF in an abap system, but I have java-stack only here, so I can't call transactions. I can only use the Visual Admin, right?, but there I could not detect a ping service so far)
    More detailed:
    I created system "SAP_WebDynpro_XSS". (this is necessary for connecting to ECC abap backend for ESS Packages) and set following parameter:
    template:"SAP system using connection string"
         category: Web Application Server
              Web AS host name: chrisSAP:50000
              Web AS path: /webdynpro/dispatcher/
              Web AS protocol: http
    But when I test the "SAP Web AS Connection" for this system, I got following error:
    7. The Web AS ping service http://chrisSAP:50000/sap/bc/ping was not pinged successfully. If the ping service is not activated on the Web AS, you can try to call the ping service manually.
    8. An HTTP/S connection to http://chrisSAP:50000/webdynpro/dispatcher/ was not
    obtained successfully; this might be due to a closed port on the Firewall.
    I guess step 8 did not pass because step 7 failed, and not because of a closed port or firewall (I made sure everything is open.)
    The strange thing is that the connection test fails, but the connection seems to work fine!
    I mean I can see the front ESS page in the portal when logging in with an ESS-user, and there are no errors in the log. If I change the SAP_WebDynpro_XSS parameters to some other made-up values, then the front ESS page does not come up and some errors appear with "SAP_WebDynpro_XSS" inside.
    That proofs that the connection is working despite the failed connection test, right?. But what can I do that the connection test passes? It seems that somehow SAP has hardcoded the path "/sap/bc/ping" which usually exists on an abap system. But I have java-stack only, so how can I tell that the function that runs the test?
    A system connection test fails, but the connection is working fine!
    If someone could explain that to me...

    Dear Srini Nookala,
    thank you for your answer. Unfortunately I don't understand the relation of my question to your answer.
    >> check with OSS note 1019335 SAP NetWeaver AS Java 6.40 SP21
    I have Version 7.0 SP14. I read the OSS note, but there are around 100 changes listed. I read them all, but couldn't figure out one that has to do with ping and system test. So which sentence inside the note are you referring to?
    >> The problem is due to JCo parameters configuration not properly, Ask Basis team, they will do it.
    I am basis team. I configured the JCo properly as described in manual and tested them afterwards. They run successful. Also all the links that you gave refer to JCO connections about how to set them up and test them. But what have JCO connections to do with System-connection tests? As far as I know JCO-connections are not used for system connectivity tests. You can set them up independent. I understand that JCO-connections are used for getting data from backend servers. But the system "SAP_WebDynpro_XSS" is defined for determing the webdynpros on localhost (frontend, not backend).
    So please can you explain me what JCO-connections which refer to remote hosts have to do with a ping service on local host that cannot be reached? And which part would be not configured "properly"? Timeouts? user?
    To define my question more properly:
    Is it possible to make the connection test work on a java-stack only host for a system that refers to itself (localhost)? Or is it a known bug?
    Some sub-questions
    Am I using the right system template (I am using "SAP system using dedicated application server")
    I have no abap on local host (chrisSAP). Only java stack. Usually path ..sap/bc/ping refers to an abap system, right? So in my opinion I have 3 possibilities:
    - install abap-stack on local host (portal) and activate ping service.
    - somehow install a ping service that runs under the given URL in Visual Admin (how?)
    - somehow tell the connection test to skip pinging and continue test. (How?)
    Any additional advice would be highly appreciated.

  • Ping time out, server connection is lost in visual administrator after java

    Dear all,
    Recently I have done system copy for XI system. I have imported the java import after importing  the abap stack into the target system as java add in abap.The import phase finished successfully and java engine is also working well.
    I have confirmed this by moving to the browser page  " http://hostname:50000/ and XI system  http://hostname:50000/rep ". Everything is working fine and in MMC console as well.
    But while trying to log in to visual administrator i am getting the error message as " ping time out,connection to server is lost "
    std_serverout.log
    unrecoverable stack overflow has occurred.
    An unexpected error has been detected by HotSpot Virtual Machine:
    EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x00000000080e3c66, pid=2940, tid=928
    Java VM: Java HotSpot(TM) 64-Bit Server VM (1.4.2_16-b05 mixed mode)
    Problematic frame:
    V  [jvm.dll+0xe3c66]
    An error report file with more information is saved as hs_err_pid2940.log
    stdout/stderr redirect
    node name   : server0
    pid         : 3060
    system name : XIT
    system nr.  : 03
    started at  : Tue Feb 17 18:42:50 2009
    CompilerOracle: exclude com/sapportals/portal/pb/layout/taglib/ContainerTag addIviewResources
    CompilerOracle: exclude com/sap/engine/services/keystore/impl/security/CodeBasedSecurityConnector getApplicationDomain
    CompilerOracle: exclude com/sap/engine/services/rmi_p4/P4StubSkeletonGenerator generateStub
    CompilerOracle: exclude com/sapportals/portal/prt/util/StringUtils escapeToJS
    CompilerOracle: exclude com/sapportals/portal/prt/core/broker/PortalServiceItem startServices
    CompilerOracle: exclude com/sap/engine/services/webservices/server/deploy/WSConfigurationHandler downloadFile
    CompilerOracle: exclude com/sapportals/portal/prt/jndisupport/util/AbstractHierarchicalContext lookup
    SAP J2EE Engine Version 6.40   PatchLevel 100627.313 is starting...
    Loading: LogManager ... 453 ms.
    Loading: PoolManager ... 0 ms.
    Loading: ApplicationThreadManager ... 94 ms.
    Loading: ThreadManager ... 31 ms.
    Loading: IpVerificationManager ... 0 ms.
    Loading: ClassLoaderManager ... 16 ms.
    Loading: ClusterManager ... 219 ms.
    Loading: LockingManager ... 93 ms.
    Loading: ConfigurationManager ... 1502 ms.
    Loading: LicensingManager ... 31 ms.
    Loading: ServiceManager ...
    6.226: [GC 6.226: [ParNew: 87040K->8544K(130560K), 0.0628724 secs] 87040K->8544K(1005056K), 0.0629982 secs]
    Loading services.:
      Service memory started. (16 ms).
      Service cross started. (15 ms).
      Service file started. (78 ms).
      Service timeout started. (32 ms).
      Service runtimeinfo started. (15 ms).
      Service userstore started. (63 ms).
      Service trex.service started. (94 ms).
      Service jmx_notification started. (63 ms).
      Service p4 started. (235 ms).
      Service classpath_resolver started. (15 ms).
    10.537: [GC 10.537: [ParNew: 95584K->16246K(130560K), 0.0776272 secs] 95584K->16246K(1005056K), 0.0777727 secs]
      Service deploy started. (3926 ms).
      Service log_configurator started. (4363 ms).
      Service locking started. (0 ms).
      Service http started. (172 ms).
      Service naming started. (203 ms).
      Service failover started. (78 ms).
      Service appclient started. (110 ms).
      Service javamail started. (140 ms).
      Service jmsconnector started. (140 ms).
      Service ts started. (125 ms).
      Service licensing started. (16 ms).
      Service connector started. (188 ms).
      Service configuration started. (31 ms).
      service MobileSetupGeneration ================= ERROR =================
      Service MobileArchiveContainer started. (78 ms).
      Service webservices started. (470 ms).
      Service dbpool started. (1172 ms).
    13.195: [GC 13.196: [ParNew: 103286K->20423K(130560K), 0.0478316 secs] 103286K->20423K(1005056K), 0.0489244 secs]
      Service com.sap.security.core.ume.service started. (2596 ms).
      Service security started. (2471 ms).
      Service classload started. (78 ms).
      Service applocking started. (141 ms).
      Service shell started. (188 ms).
      Service tceCATTPingservice started. (32 ms).
      Service telnet started. (63 ms).
    18.218: [GC 18.218: [ParNew: 107463K->25937K(130560K), 0.0545612 secs] 107463K->25937K(1005056K), 0.0546428 secs]
      Service webdynpro started. (203 ms).
      Service ejb started. (532 ms).
      Service dsr started. (172 ms).
      Service keystore started. (485 ms).
      Service ssl started. (16 ms).
      Service servlet_jsp started. (704 ms).
      Service tcsecsecurestorage~service started. (63 ms).
      Service jmx started. (391 ms).
      Service tclmctcculculservice_sda started. (0 ms).
      Service rfcengine started. (656 ms).
      Service tcsecwssec~service started. (469 ms).
      Service apptracing started. (360 ms).
    19.355: [GC 19.355: [ParNew: 112977K->42681K(130560K), 0.0844669 secs] 112977K->47563K(1005056K), 0.0845476 secs]
      Service tcsecdestinations~service started. (907 ms).
      Service basicadmin started. (860 ms).
      Service adminadapter started. (297 ms).
      Service pmi started. (312 ms).
      Service tclmctcculservice_sda started. (1251 ms).
      Service tcsecvsi~service started. (438 ms).
      Service monitor started. (407 ms).
      Service sld started. (1721 ms).
    20.296: [GC 20.296: [ParNew: 129721K->39952K(130560K), 0.1028212 secs] 134603K->50894K(1005056K), 0.1028881 secs]
      Service tc.monitoring.logviewer started. (1704 ms).
    21.584: [GC 21.584: [ParNew: 126992K->40823K(130560K), 0.0664458 secs] 137934K->58110K(1005056K), 0.0665026 secs]
      Service jms_provider started. (3518 ms).
      Service com.sap.aii.af.cpa.svc started. (2033 ms).
      Service com.sap.aii.af.security.service started. (16 ms).
      Service com.sap.aii.af.svc started. (157 ms).
    22.873: [GC 22.873: [ParNew: 127863K->43238K(130560K), 0.0574693 secs] 145150K->65266K(1005056K), 0.0575210 secs]
      Service com.sap.aii.af.ms.svc started. (407 ms).
      Service com.sap.aii.adapter.marketplace.svc started. (47 ms).
      Service com.sap.aii.adapter.bc.svc started. (47 ms).
      Service com.sap.aii.adapter.xi.svc started. (47 ms).
      Service com.sap.aii.adapter.jms.svc started. (79 ms).
      Service com.sap.aii.adapter.mail.svc started. (63 ms).
      Service com.sap.aii.adapter.jdbc.svc started. (156 ms).
      Service com.sap.aii.adapter.rfc.svc started. (219 ms).
      Service com.sap.aii.af.ispeak.svc started. (313 ms).
      Service com.sap.aii.adapter.file.svc started. (2315 ms).
    ServiceManager started for 22082 ms.
    Framework started for 24772 ms.
    SAP J2EE Engine Version 6.40   PatchLevel 100627.313 is running!
    PatchLevel 100627.313 December 14, 2005 20:06 GMT
    >26.086: [GC 26.086: [ParNew: 130278K->23111K(130560K), 0.0693509 secs] 152306K->68371K(1005056K), 0.0694372 secs]
    32.059: [GC 32.059: [ParNew: 110151K->34716K(130560K), 0.0419854 secs] 155411K->79975K(1005056K), 0.0420301 secs]
    32.608: [GC 32.608: [ParNew: 121756K->43497K(130560K), 0.0827214 secs] 167015K->105659K(1005056K), 0.0827638 secs]
    38.688: [GC 38.688: [ParNew: 130537K->39986K(130560K), 0.0525517 secs] 192699K->106409K(1005056K), 0.0526114 secs]
    41.615: [GC 41.615: [ParNew: 127026K->32598K(130560K), 0.0467433 secs] 193449K->103188K(1005056K), 0.0467930 secs]
    44.298: [GC 44.298: [ParNew: 119638K->34820K(130560K), 0.0430069 secs] 190228K->105410K(1005056K), 0.0432422 secs]
    46.443: [GC 46.443: [ParNew: 121860K->39729K(130560K), 0.0498349 secs] 192450K->110319K(1005056K), 0.0499023 secs]
    48.656: [GC 48.656: [ParNew: 126769K->36669K(130560K), 0.0625983 secs] 197359K->112667K(1005056K), 0.0626567 secs]
    52.243: [GC 52.243: [ParNew: 123709K->39589K(130560K), 0.0477260 secs] 199707K->115587K(1005056K), 0.0477793 secs]
    115.241: [GC 115.241: [ParNew: 126629K->37429K(130560K), 0.0553704 secs] 202627K->118544K(1005056K), 0.0554346 secs]
    118.096: [GC 118.096: [ParNew: 124469K->40865K(130560K), 0.0504829 secs] 205584K->121980K(1005056K), 0.0505322 secs]
    120.589: [GC 120.589: [ParNew: 127905K->37247K(130560K), 0.0578313 secs] 209020K->123954K(1005056K), 0.0578734 secs]
    122.573: [GC 122.573: [ParNew: 124287K->39626K(130560K), 0.0534208 secs] 210994K->126333K(1005056K), 0.0534640 secs]
    124.070: [GC 124.077: [ParNew: 126666K->35377K(130560K), 0.0626490 secs] 213373K->128235K(1005056K), 0.0627628 secs]
    126.103: [GC 126.103: [ParNew: 122417K->37886K(130560K), 0.0485833 secs] 215275K->130744K(1005056K), 0.0486433 secs]
    128.251: [GC 128.251: [ParNew: 124926K->41258K(130560K), 0.0482213 secs] 217784K->134115K(1005056K), 0.0482675 secs]
    130.792: [GC 130.792: [ParNew:
    Due to this i am not able to log in visual adminsitrator.Kindly advice me for the same.
    Thanks in advance
    Vijay

    Hello vamshi,
    As you have suggeseted, I followed the notes and changed the following paramters.The system is 64bit and hence the values are adjusted according to the server.
    -Djco.jarm=1
    -Dsun.io.useCanonCaches=false
    -Djava.awt.headless=true
    -XX:SoftRefLRUPolicyMSPerMB=1
    -verbose:gc
    -XX:+PrintGCDetails
    -XX:+PrintGCTimeStamps
    -Xss2m
    -Xms2048M
    -Xmx2048M
    -XX:MaxNewSize=320M
    -XX:NewSize=320M
    -XX:MaxPermSize=512M
    -XX:PermSize=512M
    -XX:SurvivorRatio=2
    -XX:TargetSurvivorRatio=90
    -XX:+UseParNewGC
    -XX:+UseTLAB
    -XX:+HeapDumpOnCtrlBreak
    The heap size for java is 2048
    But still i am getting the ping time out. Connection to server is lost.
    Kindly let me know,
    Regards
    Vijay

  • Making a ping program in java

    hey
    I know that java does'nt support ICMP protocols......and also JNI should be used if ne kind of pinging program has to be created.....
    can someone help me precisely how to do that........??
    regards and thnks
    ad

    class java.net.InetAddress
    public boolean isReachable(int timeout)
                        throws IOException
    Test whether that address is reachable. Best effort is made by the implementation to try to reach the host,
    but firewalls and server configuration may block requests resulting in a unreachable status
    while some specific ports may be accessible.
    A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained,
    otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.
    // Since: 1.5

  • Java.rmi.RemoteException: HTTP Status-Code 404 Not Found  securesimple/Ping

    Hello!
    I'm testing interop and simple application for JWSDP and I get the following error in the context:
    build-client:
    run-sample:
    [echo] Running the simple.TestClient program....
    [java] Service URL=http://localhost:8080/securesimple/Ping
    [java] Nov 4, 2004 1:31:54 PM com.sun.xml.wss.filter.DumpFilter process
    [java] INFO: ==== Sending Message Start ====
    [java] <?xml version="1.0" encoding="UTF-8"?>
    [java] <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/".............
    [java] </env:Body>
    [java] </env:Envelope>
    [java] ==== Sending Message End ====
    So, after the client has send the message this error occurs:
    [java] java.rmi.RemoteException: HTTP Status-Code 404: Not Found - /secures
    imple/Ping; nested exception is:
    [java] HTTP Status-Code 404: Not Found - /securesimple/Ping
    [java] at simple.PingPort_Stub.ping(PingPort_Stub.java:96)
    [java] at simple.TestClient.main(TestClient.java:37)
    [java] Caused by: HTTP Status-Code 404: Not Found - /securesimple/Ping
    [java] at com.sun.xml.rpc.client.http.HttpClientTransport.checkResponse
    Code(HttpClientTransport.java:302)
    [java] at com.sun.xml.rpc.client.http.HttpClientTransport.connectForRes
    ponse(HttpClientTransport.java:252)
    [java] at com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpCl
    ientTransport.java:88)
    [java] at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.
    java:92)
    [java] at simple.PingPort_Stub.ping(PingPort_Stub.java:80)
    [java] ... 1 more
    [java] Exception in thread "main"
    [java] Java Result: 1
    The application is running on localhost in a local network, so for accesing internet we're using a proxy. For this we tried to set up the proxy configuration and still the same error. We've also unplugged the network cable but it didn't help.
    We've done all the neccesary settings and we're using "org.bouncycastle.jce.provider.BouncyCastleProvider " as a JCE provider.
    Thank you!

    Just a guess, but if this is a secure web service shouldn't you be trying to connect to it using SSL? e.g.
    https://localhost:443/securesimple/Ping
    Have you tried hitting the web service via your browser and appending the ?WSDL to the URL
    http://localhost:8080/securesimple/Ping?WSDL
    https://localhost:443/securesimple/Ping?WSDL
    Can you telnet to http://localhost:8080

  • Ping Pong Game In Java

    Ello,
    Im Trying to write a simple ping pong game in a java netbeans.
    the problem is that i got the ball to move but it doesnt seem to move around the screen just in the same direction. heres the code:
    * PingPong.java
    * Created on 23 November 2006, 15:33
    * @author  rshabbir
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PingPongGame extends javax.swing.JFrame {
        /** Creates new form PingPong */
        public PingPongGame() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            jButton5 = new javax.swing.JButton();
            jButton6 = new javax.swing.JButton();
            jPanel3 = new DrawingPanel();
            getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("PING PONG");
            jPanel1.setBackground(new java.awt.Color(0, 0, 0));
            jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
            jLabel1.setFont(new java.awt.Font("Brush Script MT", 1, 14));
            jLabel1.setForeground(new java.awt.Color(255, 255, 255));
            jLabel1.setText("CONTROL PANEL");
            jButton1.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton1.setText("BAT");
            jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton1MouseClicked(evt);
            jButton2.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton2.setText("SPEED");
            jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton2MouseClicked(evt);
            jButton5.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton5.setText("BALL");
            jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton5MouseClicked(evt);
            jButton6.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton6.setText("EXIT");
            jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton6MouseClicked(evt);
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(jLabel1)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                                .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jButton6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(jButton5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap(60, Short.MAX_VALUE))
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jLabel1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 15, Short.MAX_VALUE)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton1)
                        .add(jButton5))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton6)
                        .add(jButton2))
                    .addContainerGap(38, Short.MAX_VALUE))
            getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 290, 140));
            jPanel3.setBackground(new java.awt.Color(0, 0, 0));
            org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 290, Short.MAX_VALUE)
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 370, Short.MAX_VALUE)
            getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 140, 290, 370));
            pack();
        }// </editor-fold>
        private void jButton6MouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
        private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
        private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
        private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new PingPongGame().setVisible(true);
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton5;
        private javax.swing.JButton jButton6;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JPanel jPanel1;
        private DrawingPanel jPanel3;
        // End of variables declaration
    class DrawingPanel extends JPanel
        int x,y,xdir=1,ydir=2 ;
        int interval = 30;
        int x_pos = 10;
        int y_pos = 10;
        int radius = 5;
        int x_speed = 10;
        int y_speed = 10;
        int jframesize_x = 280;
        int jframesize_y = 280;
        //int x = 150, y = 100, r=50;      // Position and radius of the circle
        //int dx = 8, dy = 5;              // Trajectory of circle
    public void paintComponent(Graphics g)
           Rectangle2D rect;
          Ellipse2D e;
           GradientPaint gp;
           Graphics2D gg;
           super.paintComponent(g);
           setBackground(new java.awt.Color(0, 0, 0));
           gg = (Graphics2D)g;
           gg.setColor(Color.red);
           rect = new Rectangle2D.Float(40, 30, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.red);
           rect = new Rectangle2D.Float(110, 30, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.red);
           rect = new Rectangle2D.Float(180, 30, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.green);
           rect = new Rectangle2D.Float(40, 60, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.green);
           rect = new Rectangle2D.Float(110, 60, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.green);
           rect = new Rectangle2D.Float(180, 60, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.blue);
           rect = new Rectangle2D.Float(40, 90, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.blue);
           rect = new Rectangle2D.Float(110, 90, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.blue);
           rect = new Rectangle2D.Float(180, 90, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.yellow);
           rect = new Rectangle2D.Float(40, 120, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.yellow);
           rect = new Rectangle2D.Float(110, 120, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.yellow);
           rect = new Rectangle2D.Float(180, 120, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.magenta);
           rect = new Rectangle2D.Float(110, 150, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.magenta);
           rect = new Rectangle2D.Float(110, 180, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.magenta);
           rect = new Rectangle2D.Float(110, 210, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.pink);
           rect = new Rectangle2D.Float(180, 150, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.pink);
           rect = new Rectangle2D.Float(180, 180, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.pink);
           rect = new Rectangle2D.Float(180, 210, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.cyan);
           rect = new Rectangle2D.Float(40, 150, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.cyan);
           rect = new Rectangle2D.Float(40, 180, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.cyan);
           rect = new Rectangle2D.Float(40, 210, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.white);
           rect = new Rectangle2D.Float(110, 350, 60, 10);
           gg.draw(rect);
           gg.fill(rect);
           //g.fillOval (x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
            try{
               Thread.sleep(15);
           } catch(InterruptedException E){}
           repaint();
           x_pos++;
           y_pos++;
           repaint();
            e = new Ellipse2D.Float(x,y,10,10); 
            gp = new GradientPaint(150,50, Color.white, 200,100, Color.white, true);
            gg.setPaint(gp);
            gg.fill(e);
            try{
               Thread.sleep(15);
           } catch(InterruptedException E){}
           repaint();
           x=x+1;
           y=y+1;
           repaint();
           if(x > jframesize_x - radius)
            x_speed = -1;
          else if(x < radius)
             x_speed = +1;
          x += x_speed;
          y += x_speed;
          x--;
          y--;
          //if ((x - r + x_pos < 0) || (x + r + x_pos > jframesize_x)) x_pos = x_pos;
          //if ((y - r + y_pos < 0) || (y + r + y_pos > jframesize_y)) y_pos = y_pos;
          //x += x_pos;  y += y_pos;
          //repaint(x-r-x_pos, y-r-x_pos, 2*r, 2*r);   // repaint old position of circle
          //repaint(x-r, y-r, 2*r, 2*r);  
         // try { Thread.sleep(50); } catch (InterruptedException e) { ; }
           

    go away. u just dont want to helpFuck off jackfuck.
    You whined the same thing in the other thread when people asked for code tags. You have also got lots of actual advice and suggestions in your other thread and ignore them all.
    Crossposting is rude but I suppose we should not expect any better from you because so far all you have demonstrated on this site is that you are rude, incredibly stupid and lazy.

  • Ping request in Java

    Hi All,
    I am developing an application in Java were in i need to discover all IP enabled devices in the Network. It can be done using ping and Broadcast ping. If any one know about this please do inform.Or any one know the other way of acheving this please do resond immediately.
    And one more query is that could we implement ICMP protocol in Java.
    Thanks in advance.
    regards
    Ravi

    You cannot effectively ping in Java. Do a search through this forum on ping. You'll get lots of hits.
    Next time, do the search first, then ask later if you absolutely cannot find what you need on your own.

  • Execute windows ping from java....

    Why don't work �?�?�?
    import java.io.*;
    class runtime{
    public static void main(String Arg[]) throws IOException
    Runtime r=Runtime.getRuntime();
    Process p= null;
    try{
    p=r.exec("ping.bat") ;
    System.out.println("Finalizo la ejecuci�n de ping");
    }catch(Exception e){ System.out.println("Error al ejecutar la instrucci�n");}
    the output is always "Finalizo la ejecucion de ping" but i don't see the output of the ping.Help me.Thxx.

    here's an example:
    public int someCall() throws Exception
    Process p;
    int intResult;
    String strExec = new String("ping java.sun.com");
    p=Runtime.getRuntime().exec(strExec); // start the process
    // now set something up that scans for output (independently)
    MGStreamGobbler mgSGErrors = new MGStreamGobbler(p.getErrorStream(),"error ");
    MGStreamGobbler mgSGOutput = new MGStreamGobbler(p.getInputStream(),"output ");
    // start the somethings
    mgSGErrors.start();
    mgSGOutput.start();
    // now wait for the actual process to end, wait for it's result
    intResult=p.waitFor();
    return(intResult);
    the StreamGobbler class - it's simple, it just waits for input and writes it,
    with a prefix, to System.out - feel free to redirect elsewhere:
    class MGStreamGobbler extends Thread
    InputStream isSource;
    String strType;
    OutputStream osGoal;
    MGStreamGobbler(InputStream isParSource, String strParType)
    isSource=isParSource;
    strType=strParType;
    public void run()
    try
    InputStreamReader isrSource = new InputStreamReader(isSource);
    BufferedReader brSource = new BufferedReader(isrSource);
    String strLine=null;
    while ( (strLine = brSource.readLine()) != null)
    System.out.println(strType + ">" + strLine);
    } catch (Exception ex)
    System.out.println(" "+ex.toString());
    if you ignore the error stream, you don't need a thread but only a while after the exec call

  • Need platform independent java code for TNS PING

    Hi, I am able to ping server /ip address. but unable to ping some TNS entry.
    There is one way to ping TNS entry using System command, but that will make my code platform dependent. i want platform independent code.. need code help for TNS Ping to database server.. here are my code:
    ---Code for server / Ip address ping:---------
    package DBM;
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.UnknownHostException;
    import java.util.ArrayList;
    import oracle.net.TNSAddress.*;
    public class PingServer
    public static void main(String[] args)
    System.out.println(" Server Pinging Starts...");
    ArrayList<String> list=new ArrayList<String>();
    list.add("g5u0660c.atlanta.hp.com");
    list.add("g1u1675c.austin.hp.com");
    list.add("gvu1785.atlanta.hp.com");
    list.add("10.130.14.109");
    list.add("10.130.0.173");
    list.add("DESCRIPTION = (SDU = 32768) (enable = broken) (LOAD_BALANCE = yes) (ADDRESS = (PROTOCOL = TCP)(HOST = gvu1515.atlanta.hp.com)(PORT = 1525))(ADDRESS = (PROTOCOL = TCP)(HOST = gvu1785.atlanta.hp.com)(PORT = 1525)");
    list.add("IDSENGI");
    //This Ipadd variable is used to convert the arraylist into String
    String ipadd="";
    try
         for(String s: list)
              ipadd=s;
              // InetAddress is class.in this class getByName()is used to take only string parameter.
              InetAddress inet = InetAddress.getByName(ipadd);
              //InetAddress inet1 =InetAddress.getAllByName("IDESENGP");
              System.out.println("Sending Ping Request to " + ipadd);
              //in InetAddress call IsReachabe(3000)method is used to ping the server IP and if ping is successfully then return true otherwise false.
              //IsReachable()take time in millisecond and return type is boolean.
              System.out.println("Host is reachable: "+inet.isReachable(3000));
         System.out.println("Server Pinging program is working fine........");
    catch (UnknownHostException e)
         System.err.println("Host does not exists");
    catch (IOException e)
         System.err.println("Error in reaching the Host");
    ----Code for TNS ping using system host----
    package DBM;
    import java.io.*;
    public class doscmd
    public static void main(String args[])
    try
    Process p=Runtime.getRuntime().exec("cmd /c tnsping IDSENGP");
    p.waitFor();
    BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line=reader.readLine();
    while(line!=null)
    System.out.println(line);
    line=reader.readLine();
    catch(IOException e1) {}
    catch(InterruptedException e2) {}
    System.out.println("Done");
    The above two codes are working absolutely fine... but need TNS ping program is platform dependent..we need to deploy it in both windows, unix...
    Please help.

    You don't need to install another JDK, just use the api from 1.2 and you should be fine. You can even use the 1.4 jdk to compile as if it were 1.2 by using the -target option in javac.

  • Obtain ping status using java

    hello guys..im new in java language and i had done few lines of codes used to ping ip address but i cant display the output in a textfile or JTextArea. as we know if we ping an IP address, the output are in a DOS form. is it possible for me to display the output either in a textfile or a JTextArea? thanks for all your help..

    this is my coding for checking the ping status and i still cant display it in the text area or textfile.where do i put ur codes?
    import javax.swing.event.*;
    import javax.swing.table.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    public class pingAP extends JPanel {
         public final static int ONE_SECOND = 1000;
         //private Timer timer;
    JTextArea output;
    JList list;
    JTable table;
    String newline = "\n";
    ListSelectionModel listSelectionModel;
    JButton start = new JButton();
    JButton ping = new JButton();
    JFileChooser buka = new JFileChooser();
    JProgressBar progressBar = new JProgressBar();
         LongTask task = new LongTask();
    public pingAP() {
    super(new BorderLayout());
    Vector data = new Vector(50);
              String[] columnNames = { "IP Address", "Location", "Equipment","Frequency(minutes)" };
    String[] oneData = { "172.24.66.10","Server Room 1 ","Ms Exchange 5.5 mail server" ,"5"};
         String[] twoData = { "", "", "", ""};
    String[] threeData = { "", "", "", ""};
    /*      String[] fourData = { "", "", "", ""};
    String[] fiveData = { "", "", "", ""};
    String[] sixData = { "", "", "", ""};
    String[] sevenData = { "", "", "", ""};
    //Build the model.
    SharedDataModel dataModel = new SharedDataModel(columnNames);
    dataModel.addElement(oneData);
              dataModel.addElement(twoData);
    dataModel.addElement(threeData);
    /* dataModel.addElement(fourData);
    dataModel.addElement(fiveData);
    dataModel.addElement(sixData);
    dataModel.addElement(sevenData);
    /*          progressBar = new JProgressBar(0, task.getLengthOfTask());
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
         list = new JList(dataModel);
    list.setCellRenderer(new DefaultListCellRenderer() {
    public Component getListCellRendererComponent(JList l,
                                                           Object value,
                                                           int i,boolean s,
                                                           boolean f) {
    String[] array = (String[])value;
    return super.getListCellRendererComponent(l,array[0],i, s, f);
              ping.addActionListener(new ActionListener() {
                                  public void actionPerformed(ActionEvent evt) {
                             pingActionPerformed(evt);
              start.addActionListener(new ActionListener() {
                                  public void actionPerformed(ActionEvent evt) {
                             startActionPerformed(evt);
    //Create a timer.
         //     timer = new Timer(ONE_SECOND, new ActionListener() {
              //public void actionPerformed(ActionEvent evt) {
              progressBar.setValue(task.getCurrent());
              output.append(task.getMessage() + newline);
              output.setCaretPosition(
              output.getDocument().getLength());
              if (task.done()) {
              Toolkit.getDefaultToolkit().beep();
         //     timer.stop();
              progressBar.setValue(progressBar.getMinimum());
    listSelectionModel = list.getSelectionModel();
         JScrollPane listPane = new JScrollPane(list);
         table = new JTable(dataModel);
    table.setSelectionModel(listSelectionModel);
    JScrollPane tablePane = new JScrollPane(table);
    //Build control area (use default FlowLayout).
    JPanel controlPane = new JPanel();
    buka.setCurrentDirectory(new java.io.File("C:\\new\\text"));
    buka.setFileSelectionMode(javax.swing.JFileChooser.FILES_ONLY);
              ping.setText("Ping");
              start.setText("Input");
              controlPane.add(start);
              controlPane.add(ping);
              controlPane.add(progressBar);
    //Build output area.
    output = new JTextArea(10, 40);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    //Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);
    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.X_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1,1));
    listContainer.setBorder(BorderFactory.createTitledBorder(
    "IP Address"));
    listContainer.add(listPane);
    JPanel tableContainer = new JPanel(new GridLayout(1,1));
    tableContainer.setBorder(BorderFactory.createTitledBorder(
    "More Info"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(300, 100));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5,5,0,5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);
    topHalf.setMinimumSize(new Dimension(400, 50));
    topHalf.setPreferredSize(new Dimension(400, 110));
    splitPane.add(topHalf);
    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.NORTH);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    bottomHalf.setPreferredSize(new Dimension(450, 135));
    splitPane.add(bottomHalf);
    //action ping status checker
    private void pingActionPerformed(ActionEvent evt) {
              task.go();
    //timer.start();
              BufferedReader in = null;
    String ipAddress = "172.24.66.143";
    try {
    Runtime r = Runtime.getRuntime();
    //Process p = r.exec("ping 172.24.66.10");
    Process p = r.exec("ping " + ipAddress );
    if (p == null) {
    System.out.println("Could not connect");
    in = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = in.readLine()) != null) {
    progressBar.setValue(task.getCurrent());
              output.append(task.getMessage() + newline);
              output.setCaretPosition(
              output.getDocument().getLength());
              if (task.done()) {
              Toolkit.getDefaultToolkit().beep();
    //          timer.stop();
              progressBar.setValue(progressBar.getMinimum());
    System.out.println(line);
    in.close();
    } catch (IOException io) {
    System.err.println(io.toString());
    //action filechooser
    private void startActionPerformed(ActionEvent evt) {
         baca(1,"");
    //File Chooser (input text file)
    String getNamePath="";
    private void baca(int type,String datapath)
    int document = 1,tabIndex=0;
    String path="", name ="";
    // if(type==1)
    buka = new JFileChooser("C:/new/text");
    buka.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int optionChosen = buka.showOpenDialog(this);
    if(optionChosen == JFileChooser.CANCEL_OPTION)
    return;
    File inFile = buka.getSelectedFile();
    path =inFile.getPath();
    name =inFile.getName();
    getNamePath = path.substring(path.lastIndexOf("\\")+1,path.length());
    /* else if(type==2)
    path="C:/new"+datapath;
    name=datapath;
         boolean hehe=true;
                        while(hehe) {
                        try{
                        FileInputStream fis = new java.io.FileInputStream(path);
                        DataInputStream myInput = new DataInputStream(fis);
                        String alamat;
                        alamat = myInput.readLine();
                                            System.out.println(alamat);
         /*indexOf(String "~", fromIndex);
         subString(int startIndex, int EndIndex)
         int haha1 = hehe.indexOf("~",0);
         int haha2 = hehe.indexOf("~",haha1+1);
         String miaw1=hehe.subString(0,haha1);
         String miaw2=hehe.subString(haha1+1,haha2);
         String miaw3=hehe.subString(haha2+1,hehe.length());
                                  output.setText(alamat);
                                            fis.close();
                        catch(FileNotFoundException ex){hehe=false;}
                        catch(Exception ex){
                        System.out.println(ex);
                        }hehe=false;
         System.out.println("success!!!!!");
    public static void main(String[] args) {
    SplashScreen screen = new SplashScreen("C:/new/splash.gif");
    screen.setVisible(false);
    JFrame frame = new JFrame("Ping Application");
              //screen.setVisible(false);
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    frame.setContentPane(new pingAP());
    frame.pack();
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              frame.setSize(new Dimension(600, 350));
    frame.setLocation((screenSize.width-600)/2,(screenSize.height-350)/2);
    frame.setVisible(true);
    class SharedDataModel extends DefaultListModel
    implements TableModel {
    public String[] columnNames;
    public SharedDataModel(String[] columnNames) {
    super();
    this.columnNames = columnNames;
    public void rowChanged(int row) {
    fireContentsChanged(this, row, row);
    private TableModel tableModel = new AbstractTableModel() {
    public String getColumnName(int column) {
    return columnNames[column];
    public int getRowCount() {
    return size();
    public int getColumnCount() {
    return columnNames.length;
    public Object getValueAt(int row, int column) {
    String[] rowData = (String [])elementAt(row);
    return rowData[column];
    public boolean isCellEditable(int row, int column) {
    return true;
    public void setValueAt(Object value, int row, int column) {
    String newValue = (String)value;
    String[] rowData = (String [])elementAt(row);
    rowData[column] = newValue;
    fireTableCellUpdated(row, column); //table event
    rowChanged(row); //list event
    //Implement the TableModel interface.
    public int getRowCount() {
    return tableModel.getRowCount();
    public int getColumnCount() {
    return tableModel.getColumnCount();
    public String getColumnName(int columnIndex) {
    return tableModel.getColumnName(columnIndex);
    public Class getColumnClass(int columnIndex) {
    return tableModel.getColumnClass(columnIndex);
    public boolean isCellEditable(int rowIndex, int columnIndex) {
    return tableModel.isCellEditable(rowIndex, columnIndex);
    public Object getValueAt(int rowIndex, int columnIndex) {
    return tableModel.getValueAt(rowIndex, columnIndex);
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    tableModel.setValueAt(aValue, rowIndex, columnIndex);
    public void addTableModelListener(TableModelListener l) {
    tableModel.addTableModelListener(l);
    public void removeTableModelListener(TableModelListener l) {
    tableModel.removeTableModelListener(l);

  • Ping test in Java

    Hello everyone!
    Is there a way that I can call a "ping" test from a java program and catch the results? I basically want to right a program that runs through an entire list of IP addresses and verify whether I can talk to those devices or not. I know how to create the variables and display them, I'm just not sure how to actually perform the actual "ping".
    Thanks!

    I had the same problem a few months ago when I had had to write a network performance monitor.
    I ended up with the following code:
         try {
         Runtime r = Runtime.getRuntime();
         Process p = r.exec("ping 172.20.1.2 -n 1");
         BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
         // Insert some code here to read and parse the returned string...
         catch (IOException e) {
         e.printStackTrace();
    If you like I could mail you the entire code.
    Andy.

Maybe you are looking for

  • I want to use my iPOD only for music.  How do I delete my congtacts and calendar entries?

    I want to use my iPOD Touch only for music.  How do I delete my contact and calendar entires?

  • Reg: IDOC Status Info Report

    Hi Experts I am trying to posting the products/internal orders data via IDOC/ALE. After the Data loaded into the target system,I required to display the below info: Initial Data Load Results Report Layout: Totals Total number of records read: Total n

  • Duplicate Reciept number check in POS inbound

    Dear All, How can i restrict the SAP system, if ithe same duplicate transaction reciept number(ex: 00010009696) is coming from POS twice, while doing Non sales aggregated transaction. what configuration setting is required for this check, i have trie

  • Remove an embeded font from a PDF

    Hi Guys I have a bunch of PDF's where I need to remove a sertant font due to Copyright reason. When I use the PDF optimizer and unembed the font, it replaces the font with another all over the PDF, but when I open the optimized PDF and check the prop

  • Approving shopping cart w/o account

    hi i have an issue related to approvals. User is not having the Fixed Asset Clerk A/C in org structure,eventhough he is Approving the shopping cart(Awaiting Approval). so how it is posible.please advise me. Regards Sai