ping and traceroute java program
simple java program for ping and traceroute

To execute ping and tracert commands through runtime environment like java..
by the following program

To execute ping and tracert commands through runtime environment like java..
by the following program
PING PROGRAM:
import java.io.*;
public class kutty
{
public static void runSystemCommand(String Command)
{
try{
Process p=Runtime.getRuntime().exec(Command);
BufferedReader InputStream=new BufferedReader(new InputStreamReader(p.getInputStream()));
String s=” “;
while((s=InputStream.readLine())!=null)
{
System.out.println(s);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[]args)
{
String Ip=”localhost”;
public class kutty
{
public static void runSystemCommand(String Command)
{
try{
Process p=Runtime.getRuntime().exec(Command);
BufferedReader InputStream=new BufferedReader(new InputStreamReader(p.getInputStream()));
String s=” “;
while((s=InputStream.readLine())!=null)
{
System.out.println(s);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[]args)
{
String Ip=”localhost”;
runSystemCommand(“ping ” +Ip);
java.util.Date date=new java.util.Date();
System.out.println(date);
}
}
java.util.Date date=new java.util.Date();
System.out.println(date);
}
}
TRACE ROUTE PROGRAM:
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class kutty
{
public static void runSystemCommand(String Command)
{
try{
Process p=Runtime.getRuntime().exec(Command);
BufferedReader InputStream=new BufferedReader(new InputStreamReader(p.getInputStream()));
String s=” “;
while((s=InputStream.readLine())!=null)
{
System.out.println(s);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[]args)
{
String Ip=” 67.195.160.76″;
import java.io.InputStreamReader;
public class kutty
{
public static void runSystemCommand(String Command)
{
try{
Process p=Runtime.getRuntime().exec(Command);
BufferedReader InputStream=new BufferedReader(new InputStreamReader(p.getInputStream()));
String s=” “;
while((s=InputStream.readLine())!=null)
{
System.out.println(s);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[]args)
{
String Ip=” 67.195.160.76″;
runSystemCommand(“tracert” +Ip);
java.util.Date date=new java.util.Date();
System.out.println(date);
}
}
java.util.Date date=new java.util.Date();
System.out.println(date);
}
}
0 comments:
Post a Comment