I have been working on a program that Should Scan a small Subnet i.e for eg 10.1.1.1 to 10.1.1.255 with the subnet mask 255.255.255.0

I am attaching screenshots of the main screen of my project as "Screenshot 1" source code :jMenu.java

I am posting the code here:

package projectpack;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.geom.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.JTable;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;






public class jMenu extends JFrame implements ActionListener
{
JFrame jf; 
JPanel jp;
JScrollPane pane;

Container c1;

     	
	
JTable table;
JLabel l;
JLabel l2;
JLabel lbl5;
JLabel l3;
JLabel lbl2;
JTextField jt;
JTextField jt2;
JButton b1;
JButton b2;
String lbl;
	JButton b3;
String lb2; 
	JButton b4;
JButton b5;
JMenu f;
	JMenuItem it1,it2,it3,it4,it5,it6,it7,it8,it9,it10,it11,it12 ;
	JMenu m1,m2,m3,m4,m5;
JMenuBar bar;



  
   public jMenu()
 {
 String str="Network Watcher v2";
 jf=new JFrame(str); 
 jp = new JPanel();//panel
 c1=jf.getContentPane();

 
 l=new JLabel("Hostname");
 l2=new JLabel("IP"); //label ip

 jt=new JTextField(16); //text box host
 jt2=new JTextField(16); //textbox 2 IP
 b1=new JButton("Look Up"); //button 1 checking IP address
 b2=new JButton("Mobile"); //button 1 checking IP address
 lbl = "<html>" + "Desktop" + "<br>" + "  "+"View" + "</html>";
	 b3=new JButton(lbl); //button 1 checking IP address
 lb2 = "<html>" + "File" + "<br>" + "  "+"Transfer" + "</html>";
	 b4=new JButton(lb2); //button 1 checking IP address
 b5=new JButton("Scan"); 
JMenu f=new JMenu(); //menu
	
it1=new JMenuItem("Export all");
	it2=new JMenuItem("Export Selection");
	it3=new JMenuItem("Exit");
	it4=new JMenuItem("Next Alive Host");
	it5=new JMenuItem("Next Open Port");
                 it6=new JMenuItem("Show Details");
                 it7=new JMenuItem("Rescan IP");
                 it8=new JMenuItem("Delete IP");
                 it9=new JMenuItem("Preferences");
                 it10=new JMenuItem("Fetchers");	
	it11=new JMenuItem("About");
	it12=new JMenuItem("Getting Started");
	
	m1=new JMenu("File");
	m2=new JMenu("GOTO");
	m3=new JMenu("Commands");
	m4=new JMenu("Tools");
	m5=new JMenu("Help");
	 bar=new JMenuBar();
                  b5.addActionListener(this);
	
	
       	
	c1.setLayout(null);
	
	
	jp.setBounds(0,0,1200,296);

	Color colorlightgreen=new Color(242,248,252);
               	jp.setBackground(colorlightgreen);
	
	




//+++++++++++++++++++++++TABLE and Table DATA++++++++++++++++++++++++++++++++++++++++++++++++

String data[][] = {{"", "", "",""},
{"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    
                    
 
 };

  String fields[] = {"IP", "HOST", "PORTS","WEBDETECT"};
table = new JTable( data, fields );
   pane = new JScrollPane( table );
pane.setBounds(0,300,1015,400);


     	  

 
    
	
//+++++++++++++++++++++++labels and texts++++++++++++++++++++++++++++++++++++++++++++++++++	
	
	l.setBounds(0,45,200,100);//positions a component onto the screen
	
	l2.setBounds(0,85,200,100);
	 l3=new JLabel("===========================================================================================================================================================================================================");
	l3.setBounds(0,260,1100,40);//positions a component onto the screen
	
	
	
	
	
	jt.setBounds(65,85,70,22);
	
	jt2.setBounds(65,120,70,22);	
//++++++++++++++++++++++Buttons++++++++++++++++++++++++++++++++++++++++++++++++++++                 


	
                	b1.setBounds(170,95,85,35);
	
                	b2.setBounds(500,60,100,100);
	
              	b3.setBounds(700,60,100,100);
	
                	b4.setBounds(900,60,100,100);
	
	
	b5.addActionListener(this);
	b5.setBounds(300,60,100,100);
	jp.add(b5);
	
   

	
	
		
//++++++++++++++++++++++++++++++Menu and Menu Items+++++++++++++++++++++++++++++++++++++++++++		
  
   	
	
	m1.add(it1);
	m1.add(it2);
	m1.add(it3);
	
	m2.add(it4);
	m2.add(it5);
	
	m3.add(it6);
	m3.add(it7);
	m3.add(it8);
	
	m4.add(it9);
	m4.add(it10);
	
	m5.add(it11);
	m5.add(it12);
	
	
	bar.add(m1);
	bar.add(m2);
 	bar.add(m3);
 	bar.add(m4);
	bar.add(m5);
	bar.setBorderPainted(false);
	bar.setBounds(0,0,1100,30);
	
	bar.setBackground(colorlightgreen);
//++++++++++++++++++++++++++++++++++++Adding components onto panels++++++++++++++++++++++++++++++++++
	jp.add(l);
	jp.add(l2);//jp.add(l3);
	jp.add(bar);
	jp.add(jt);
	jp.add(jt2);
                 jp.add(b1);
	jp.add(b2);
	jp.add(b3);
	jp.add(b4);
	//jp.add(b5);
	
	jp.setLayout(null);
                 

	
               
	
	
	c1.add(jp);
	c1.add(pane);
	jf.show();
 	
	
	
	jf.setSize(new Dimension(1024,768));
	jf.setVisible(true);
 	
	jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
}






public static void main(String args[])
	{
 	 jMenu jj=new jMenu();
//++++++++++++++++++++++++++++++Frame Container and panel+++++++++++++++++++++++++++++++++++++
	

}
public void wait4scan()
{
IpPingmod startPing=new IpPingmod();
startPing.gen_ip();
startPing.xxx();
	
	while(IpPingmod.scan_fin==false)
{
}



}

	
public void actionPerformed(ActionEvent ae){
{
	
	
	if(ae.getSource()==b5)
	  {
	ImageIcon icon=new ImageIcon("D:\\ProjectP\\images\\SCANNING_23235.gif");
	lbl2=new JLabel();
	lbl2.setIcon(icon);
	lbl2.setBounds(0,200,1200,100);
	jp.add(lbl2);
	jp.updateUI();
	b1.setEnabled(false);
	b2.setEnabled(false);
	b3.setEnabled(false);
	b4.setEnabled(false);
	b5.setEnabled(false);
	table.setEnabled(false);
	bar.setEnabled(false);
	m1.setEnabled(false);
	m2.setEnabled(false);
	m3.setEnabled(false);
	m4.setEnabled(false);
	m5.setEnabled(false);
	jt.setEnabled(false);
	jt2.setEnabled(false);
	jp.updateUI();
	//this.wait4scan();
	
	
	}
                          
};









     



}}

There is an another source code file which i have created in the same package that will do the work for me,it contains 25 classes each will then be a thread,out of which 1st 24 will scan 10 hosts in the subnet,and the last class wil scan 15 remaining hosts in a 255 host subnet.I am using the windows command Ping to scan the hosts,ICMP PING,

((Process p1 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j]=p1.waitFor();  //  wait for returns 0 if alive otherwise 1))

for eg if the subnet is 10.40.104
class "Ping1" will scan hosts from 10.40.104.1 to 10.40.104.10
class "Ping2" will scan hosts from 10.40.104.11 to 10.40.104.20
and so on....till Ping25
I am posting the code file named "IpPingmod.java" here

package projectpack;
import java.io.*;
import java.net.*;
import java.awt.*;


public class IpPingmod extends Thread
{
	public static boolean scan_fin=false;
    	public static String ipAdd[]=new String[256];
	public static volatile String subnet;
    	public static volatile int status[]=new int[256];
    	public static String[] aliveIp=new String[256];
    	public static String[] aliveIp2=new String[256];
public IpPingmod()
{
	  	
	try{
	InetAddress ia=InetAddress.getLocalHost();
	String Ip=ia.getHostAddress();
	int occ_of_dot=Ip.lastIndexOf(".");
	subnet=Ip.substring(0,occ_of_dot); 
	}catch(Exception e)
	{
	System.out.println(e.getMessage());
	}
	
}
	public void xxx()
{

	Ping1 one=new Ping1();Ping2 two=new Ping2();Ping3 three=new Ping3();Ping4 four=new Ping4();Ping5 five=new Ping5();Ping6 six=new Ping6();Ping7 seven=new Ping7();Ping8 eight=new Ping8();Ping9 nine=new Ping9();Ping10 ten=new Ping10();Ping11 eleven=new Ping11();Ping12 twelve=new Ping12();Ping13 thirteen=new Ping13();Ping14 fourteen=new Ping14();Ping15 fifteen=new Ping15();Ping16 sixteen=new Ping16();Ping17 seventeen=new Ping17();Ping18 eighteen=new Ping18();Ping19 nineteen=new Ping19();Ping20 twenty=new Ping20();Ping21 twentyone=new Ping21();Ping22 twentytwo=new Ping22();Ping23 twentythree=new Ping23();Ping24 twentyfour=new Ping24();Ping25 twentyfive=new Ping25();
	one.start();two.start();three.start();four.start();five.start();six.start();seven.start();eight.start();nine.start();ten.start();eleven.start();twelve.start();thirteen.start();fourteen.start();fifteen.start();sixteen.start();seventeen.start();eighteen.start();nineteen.start();twenty.start();twentyone.start();twentytwo.start();twentythree.start();twentyfour.start();twentyfive.start();
	
}	
	
	
	
  	
	
    

    

	
 public void gen_ip()
{
  ipAdd[0]=subnet+"."+"0";
for(int i=1;i<=255;i++)
   {
     ipAdd[i]=subnet+"."+i;
}
}
}

class Ping1 extends Thread
{ 


public synchronized void run()
{

for(int j=0;j<11;j++)
{
	try{
	this.sleep((long)(Math.random() * 100));
	Process p1 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j]=p1.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}

}

 
} 


//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


class Ping2 extends Thread
{


public synchronized void run()
{
for(int j=11;j<21;j++)
{
	try{
	this.sleep((long)(Math.random() * 100));
	Process p2 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j]= p2.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}
class Ping3 extends Thread
{


public synchronized void run()
{
for(int j=21;j<31;j++)
{
	try{
	this.sleep((long)(Math.random() * 100));
	Process p3 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j]=p3.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{	
	System.out.println(e);
	}


}
} 
}
//class3 ends
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping4 extends Thread
{


public synchronized void run()
{
 for(int j=31;j<41;j++)
{
	
	try
	{
	this.sleep((long)(Math.random() * 100));
	Process p4 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p4.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}
} 
}

}  

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping5 extends Thread
{


public synchronized void run()
{
for(int j=41;j<51;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p5 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p5.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));


	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping6 extends Thread
{


public synchronized void run()
{
for(int j=51;j<61;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p6 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p6.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}
} 
}
}


//class 6 ends
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping7 extends Thread
{


public synchronized void run()
{
for(int j=61;j<71;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p7 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p7.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}
} 
} 
}
//class 7 ends

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping8 extends Thread
{


public synchronized void run()
{
for(int j=71;j<81;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p8 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p8.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}
//class 8 ends

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping9 extends Thread
{


public synchronized void run()
{
for(int j=81;j<91;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p9 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p9.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}
//class 9 ends

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping10 extends Thread
{


public synchronized void run()
{
for(int j=91;j<101;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p10 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p10.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 10 ends
class Ping11 extends Thread
{


public synchronized void run()
{
for(int j=101;j<111;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p11 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p11.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 11 ends
class Ping12 extends Thread
{


public synchronized void run()
{
for(int j=111;j<121;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p12 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p12.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 12 ends
class Ping13 extends Thread
{


public synchronized void run()
{
for(int j=121;j<131;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p13 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p13.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 13 ends
class Ping14 extends Thread
{


public synchronized void run()
{
for(int j=131;j<141;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p14 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p14.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 14 ends
class Ping15 extends Thread
{


public synchronized void run()
{
for(int j=141;j<151;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p15 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p15.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 15 ends
class Ping16 extends Thread
{


public synchronized void run()
{
for(int j=151;j<161;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p16 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p16.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 16 ends
class Ping17 extends Thread
{


public synchronized void run()
{
for(int j=161;j<171;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p17 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p17.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 17 ends
class Ping18 extends Thread
{


public synchronized void run()
{
for(int j=171;j<181;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p18 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p18.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 18 ends
class Ping19 extends Thread
{


public synchronized void run()
{
for(int j=181;j<191;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p19 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p19.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 19 ends
class Ping20 extends Thread
{


public synchronized void run()
{
for(int j=191;j<201;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p20 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p20.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 20 ends
class Ping21 extends Thread
{


public synchronized void run()
{
for(int j=201;j<211;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p21 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p21.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 21 ends
class Ping22 extends Thread
{


public synchronized void run()
{
for(int j=211;j<221;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p22 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p22.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 22ends
class Ping23 extends Thread
{


public synchronized void run()
{
for(int j=221;j<231;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p23 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p23.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 23 ends
class Ping24 extends Thread
{


public synchronized void run()
{
for(int j=231;j<241;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p24 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p24.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 24 ends
class Ping25 extends Thread
{

public static boolean beep=false;
public synchronized void run()
{
for(int j=241;j<256;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p25 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmod.status[j] = p25.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}

	for(int i=0;i<256;i++)
{		
		if(IpPingmod.status[i]==0)
		IpPingmod.aliveIp[i]=IpPingmod.ipAdd[i];
		else
		IpPingmod.aliveIp[i]="not alive";
				
		

}
for(int i=0;i<256;i++)
{
	if(!(IpPingmod.aliveIp[i].equals("not alive")))
{	
	IpPingmod.aliveIp2[i]=IpPingmod.aliveIp[i];//now aliveIp2 contains the list of IP addresses which are alive;
	System.out.println(IpPingmod.aliveIp2[i]);
}

}

try {
			System.out.print ( "\007" );
			System.out.flush(); 
			Ping25.beep=true;
		} catch (Exception e) {
			e.printStackTrace();
		}

if(Ping25.beep==true)
IpPingmod.scan_fin=true;



} //run completes
}
//class 25 ends

PROBLEM HERE:Now when i start the program jMenu from the command line,it starts off well with the UI in place...but
when i click the Scan Button
i can see various ping process in the background in the Windows Task manager and the java.exe process which takes 99% of the CPU all the time.

The BIG problem: computer stops responding at this time.may be because all the CPU is used by java.exe .

A BIG Surprise:when i run the IpPingmod.java program Using MAIN in the code and with some modifications and the logic being the same its works well does the job for me without using most of CPU.

I WANT A SOLUTION FOR THIS.SO THAT I CAN USE THE IpPingmod.java IN THE SAME PACKAGE AND USE IT FROM jMenu.java


Or please somebody help me with the IsReachable method of InetAddress for the whole subnet.

below are the screenshots for my program jMenu

First of all, why 25 different ping classes? Simply create one with a constructor that takes parameters.

And then you start 25 threads that each start an additional 10 processes and you're wondering why it might take a bit of time?

And, you're performing all of these actions in the event thread (which should be worried about nothing other than updating the GUI).

It would probably be helpful to know exactly what "some modifications" means.

Also, the stdout and stderr have only so much buffer size, and if you fill those buffers then the app will hang until you read them. Read http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html completely and thoroughly.

Also, you're setting "scan_fin" true as soon as ping 25 is done (which doesn't necessarily mean they are all done, since 25 could run faster than some of the others and they are all running at the same time). And you should be synchronising access to that variable also.

And, currently, pushing scan does nothing as in this code you've commented out the only method call that would have done something.

You need to do some more general studying about the GUI event thread, threads in general, and Runtime Exec.

Thank you so much for your help masijade
I went through the Runtime.exec() issue page on javaWorld
but i guess the method works fine for me.
here is the video dat wil make things clear :please have a look at it
http://rapidshare.com/files/186435781/problem_the_GUI_hangs.avi

Also i have made changes to my code
jMenu.java

package projectpack;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import javax.swing.table.DefaultTableModel;
import javax.swing.JTable;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;






public class jMenu extends JFrame implements ActionListener
{
JFrame jf; 
JPanel jp;
JScrollPane pane;

Container c1;

     	
	
JTable table;
JLabel l;
JLabel l2;
JLabel lbl5;
JLabel l3;
JLabel lbl2;
JTextField jt;
JTextField jt2;
JButton b1;
JButton b2;
String lbl;
	JButton b3;
String lb2; 
	JButton b4;
JButton b5;
JMenu f;
	JMenuItem it1,it2,it3,it4,it5,it6,it7,it8,it9,it10,it11,it12 ;
	JMenu m1,m2,m3,m4,m5;
JMenuBar bar;



  
   public jMenu()
 {
 String str="Network Watcher v2";
 jf=new JFrame(str); 
 jp = new JPanel();//panel
 c1=jf.getContentPane();

 
 l=new JLabel("Hostname");
 l2=new JLabel("IP"); //label ip

 jt=new JTextField(16); //text box host
 jt2=new JTextField(16); //textbox 2 IP
 b1=new JButton("Look Up"); //button 1 checking IP address
 b2=new JButton("Mobile"); //button 1 checking IP address
 lbl = "<html>" + "Desktop" + "<br>" + "  "+"View" + "</html>";
	 b3=new JButton(lbl); //button 1 checking IP address
 lb2 = "<html>" + "File" + "<br>" + "  "+"Transfer" + "</html>";
	 b4=new JButton(lb2); //button 1 checking IP address
 b5=new JButton("Scan"); 
JMenu f=new JMenu(); //menu
	
it1=new JMenuItem("Export all");
	it2=new JMenuItem("Export Selection");
	it3=new JMenuItem("Exit");
	it4=new JMenuItem("Next Alive Host");
	it5=new JMenuItem("Next Open Port");
                 it6=new JMenuItem("Show Details");
                 it7=new JMenuItem("Rescan IP");
                 it8=new JMenuItem("Delete IP");
                 it9=new JMenuItem("Preferences");
                 it10=new JMenuItem("Fetchers");	
	it11=new JMenuItem("About");
	it12=new JMenuItem("Getting Started");
	
	m1=new JMenu("File");
	m2=new JMenu("GOTO");
	m3=new JMenu("Commands");
	m4=new JMenu("Tools");
	m5=new JMenu("Help");
	 bar=new JMenuBar();
                  b5.addActionListener(this);
	
	
       	
	c1.setLayout(null);
	
	
	jp.setBounds(0,0,1200,296);

	Color colorlightgreen=new Color(242,248,252);
               	jp.setBackground(colorlightgreen);
	
	




//+++++++++++++++++++++++TABLE and Table DATA++++++++++++++++++++++++++++++++++++++++++++++++

String data[][] = {{"", "", "",""},
{"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    {"", "", "",""},
                    
                    
 
 };

  String fields[] = {"IP", "HOST", "PORTS","WEBDETECT"};
table = new JTable( data, fields );
   pane = new JScrollPane( table );
pane.setBounds(0,300,1015,400);


     	  

 
    
	
//+++++++++++++++++++++++labels and texts++++++++++++++++++++++++++++++++++++++++++++++++++	
	
	l.setBounds(0,45,200,100);//positions a component onto the screen
	
	l2.setBounds(0,85,200,100);
	 l3=new JLabel("===========================================================================================================================================================================================================");
	l3.setBounds(0,260,1100,40);//positions a component onto the screen
	
	
	
	
	
	jt.setBounds(65,85,70,22);
	
	jt2.setBounds(65,120,70,22);	
//++++++++++++++++++++++Buttons++++++++++++++++++++++++++++++++++++++++++++++++++++                 


	
                	b1.setBounds(170,95,85,35);
	
                	b2.setBounds(500,60,100,100);
	
              	b3.setBounds(700,60,100,100);
	
                	b4.setBounds(900,60,100,100);
	
	
	b5.addActionListener(this);
	b5.setBounds(300,60,100,100);
	jp.add(b5);
	
   

	
	
		
//++++++++++++++++++++++++++++++Menu and Menu Items+++++++++++++++++++++++++++++++++++++++++++		
  
   	
	
	m1.add(it1);
	m1.add(it2);
	m1.add(it3);
	
	m2.add(it4);
	m2.add(it5);
	
	m3.add(it6);
	m3.add(it7);
	m3.add(it8);
	
	m4.add(it9);
	m4.add(it10);
	
	m5.add(it11);
	m5.add(it12);
	
	
	bar.add(m1);
	bar.add(m2);
 	bar.add(m3);
 	bar.add(m4);
	bar.add(m5);
	bar.setBorderPainted(false);
	bar.setBounds(0,0,1100,30);
	
	bar.setBackground(colorlightgreen);
//++++++++++++++++++++++++++++++++++++Adding components onto panels++++++++++++++++++++++++++++++++++
	jp.add(l);
	jp.add(l2);//jp.add(l3);
	jp.add(bar);
	jp.add(jt);
	jp.add(jt2);
                 jp.add(b1);
	jp.add(b2);
	jp.add(b3);
	jp.add(b4);
	//jp.add(b5);
	
	jp.setLayout(null);
                 

	
               
	
	
	c1.add(jp);
	c1.add(pane);
	jf.show();
 	
	
	
	jf.setSize(new Dimension(1024,768));
	jf.setVisible(true);
 	
	jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
}





//++++++++++++++++++++++++++++++MAIN+++++++++++++++++++++++++++++++++++++++++++++++++++++
public static void main(String args[])
	{
 	jMenu jj=new jMenu();
	
	
	

}


//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



//+++++++++++++++++++++++++++++++wait4scan()++++++++++++++++++++++++++++++++++++++++++++++++++
public void wait4scan()
{

IpPingmodEdit one=new IpPingmodEdit(1);
	one.setSubnet();
	one.gen_ip();
	one.scanlan();

}



//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	

//+++++++++++++++++++++++++++++++++actionPerformed+++++++++++++++++++++++++++++++++++++++++++

public void actionPerformed(ActionEvent ae){
{
	
	
	if(ae.getSource()==b5)
	  {
	ImageIcon icon=new ImageIcon("D:\\ProjectP\\images\\SCANNING_23235.gif");
	lbl2=new JLabel();
	lbl2.setIcon(icon);
	lbl2.setBounds(0,200,1200,100);
	jp.add(lbl2);
	jp.updateUI();
	b1.setEnabled(false);
	b2.setEnabled(false);
	b3.setEnabled(false);
	b4.setEnabled(false);
	b5.setEnabled(false);
	table.setEnabled(false);
	bar.setEnabled(false);
	m1.setEnabled(false);
	m2.setEnabled(false);
	m3.setEnabled(false);
	m4.setEnabled(false);
	m5.setEnabled(false);
	jt.setEnabled(false);
	jt2.setEnabled(false);
	jp.updateUI(); //update before a call to the method dat has runtime class objects
	this.wait4scan();
	
	}
                          
};

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++







     



}}

IpPingmodEdit.java

package projectpack;
import java.io.*;
import java.net.*;
import java.awt.*;


public class IpPingmodEdit extends Thread
{
	public static boolean scan_fin=false;
    	public static String ipAdd[]=new String[256];               //IpAddress of 255 hosts in the subnet
	public static volatile String subnet;		// the Subnet address	
    	public static volatile int status[]=new int[256];	//status of each ip
    	public static String[] aliveIp=new String[256];	//
    	public static String[] aliveIp2=new String[256];	//list of alive Ips
	public int range_starts_at;
	public int range_ends_at;
	public int object_no;
public IpPingmodEdit(int objno)
{
this.range_ends_at=(objno*10);
this.range_starts_at=(range_ends_at-9);



	  	
	
}

//++++++++++++++++++++++++++++++++++++++++++setSubnet()+++++++++++++++++++++++++++++++++++++++++++

public static void setSubnet()
{
try{
	InetAddress ia=InetAddress.getLocalHost();
	String Ip=ia.getHostAddress();
	int occ_of_dot=Ip.lastIndexOf(".");
	subnet=Ip.substring(0,occ_of_dot); 
	}catch(Exception e)
	{
	System.out.println(e.getMessage());
	}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++MAIN+++++++++++++++++++++++++++++++++++++++++++
/*	public static void main(Sting args[])
{

//Main is not used,it is kept for experimental purposes;	
	
}	
	
	
	
  	
*/	
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    

//setSubnet should be called prior to genip()    

//+++++++++++++++++++++++++++++++++++++genip()++++++++++++++++++++++++++++++++++++++++++++++	
 public void gen_ip()
{
  ipAdd[0]=subnet+"."+"0";
for(int i=1;i<=255;i++)
   {
     ipAdd[i]=subnet+"."+i;
}
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//++++++++++++++++++++++++++++++++++++scanlan()++++++++++++++++++++++++++++++++++++++++++++++
public void scanlan()
{
for(int j=1;j<=10;j++)
{

try{
	//this.sleep((long)(Math.random() * 100));
	Process p1 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j]=p1.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmod.ipAdd[j] + " is " + (IpPingmod.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}
}

}






















}

//all the classes in the code are now replaced by the constructor and the objects wil be created in jMenu.java
/*

class Ping1 extends Thread
{ 


public synchronized void run()
{

for(int j=0;j<11;j++)
{
	try{
	this.sleep((long)(Math.random() * 100));
	Process p1 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmod.ipAdd[j]);
     	IpPingmodEdit.status[j]=p1.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}

}

 
} 


//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


class Ping2 extends Thread
{


public synchronized void run()
{
for(int j=11;j<21;j++)
{
	try{
	this.sleep((long)(Math.random() * 100));
	Process p2 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j]= p2.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}
class Ping3 extends Thread
{


public synchronized void run()
{
for(int j=21;j<31;j++)
{
	try{
	this.sleep((long)(Math.random() * 100));
	Process p3 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j]=p3.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{	
	System.out.println(e);
	}


}
} 
}
//class3 ends
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping4 extends Thread
{


public synchronized void run()
{
 for(int j=31;j<41;j++)
{
	
	try
	{
	this.sleep((long)(Math.random() * 100));
	Process p4 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p4.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}
} 
}

}  

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping5 extends Thread
{


public synchronized void run()
{
for(int j=41;j<51;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p5 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p5.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping6 extends Thread
{


public synchronized void run()
{
for(int j=51;j<61;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p6 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p6.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}
} 
}
}


//class 6 ends
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping7 extends Thread
{


public synchronized void run()
{
for(int j=61;j<71;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p7 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p7.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}
} 
} 
}
//class 7 ends

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping8 extends Thread
{


public synchronized void run()
{
for(int j=71;j<81;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p8 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p8.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}
//class 8 ends

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping9 extends Thread
{


public synchronized void run()
{
for(int j=81;j<91;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 100));
	Process p9 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p9.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}


    
} 
}
//class 9 ends

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Ping10 extends Thread
{


public synchronized void run()
{
for(int j=91;j<101;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p10 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p10.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 10 ends
class Ping11 extends Thread
{


public synchronized void run()
{
for(int j=101;j<111;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p11 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p11.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 11 ends
class Ping12 extends Thread
{


public synchronized void run()
{
for(int j=111;j<121;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p12 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p12.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 12 ends
class Ping13 extends Thread
{


public synchronized void run()
{
for(int j=121;j<131;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p13 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p13.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 13 ends
class Ping14 extends Thread
{


public synchronized void run()
{
for(int j=131;j<141;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p14 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p14.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 14 ends
class Ping15 extends Thread
{


public synchronized void run()
{
for(int j=141;j<151;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p15 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p15.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 15 ends
class Ping16 extends Thread
{


public synchronized void run()
{
for(int j=151;j<161;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p16 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p16.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 16 ends
class Ping17 extends Thread
{


public synchronized void run()
{
for(int j=161;j<171;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p17 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p17.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 17 ends
class Ping18 extends Thread
{


public synchronized void run()
{
for(int j=171;j<181;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p18 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p18.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 18 ends
class Ping19 extends Thread
{


public synchronized void run()
{
for(int j=181;j<191;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p19 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p19.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 19 ends
class Ping20 extends Thread
{


public synchronized void run()
{
for(int j=191;j<201;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p20 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p20.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 20 ends
class Ping21 extends Thread
{


public synchronized void run()
{
for(int j=201;j<211;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p21 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p21.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 21 ends
class Ping22 extends Thread
{


public synchronized void run()
{
for(int j=211;j<221;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p22 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p22.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 22ends
class Ping23 extends Thread
{


public synchronized void run()
{
for(int j=221;j<231;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p23 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p23.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 23 ends
class Ping24 extends Thread
{


public synchronized void run()
{
for(int j=231;j<241;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p24 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p24.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}
} 
}
//class 24 ends
class Ping25 extends Thread
{

public static boolean beep=false;
public synchronized void run()
{
for(int j=241;j<256;j++)
{
	
	try{
	this.sleep((long)(Math.random() * 10));
 	Process p25 = Runtime.getRuntime().exec("ping -n 1 " +IpPingmodEdit.ipAdd[j]);
     	IpPingmodEdit.status[j] = p25.waitFor();  //  wait for returns 0 if alive otherwise 1
     	//System.out.println(IpPingmodEdit.ipAdd[j] + " is " + (IpPingmodEdit.status[j]==0 ? "alive" : "dead"));
	}catch(Exception e)
	{
	System.out.println(e);
	}

}

	for(int i=0;i<256;i++)
{		
		if(IpPingmodEdit.status[i]==0)
		IpPingmodEdit.aliveIp[i]=IpPingmodEdit.ipAdd[i];
		else
		IpPingmodEdit.aliveIp[i]="not alive";
				
		

}
for(int i=0;i<256;i++)
{
	if(!(IpPingmodEdit.aliveIp[i].equals("not alive")))
{	
	IpPingmodEdit.aliveIp2[i]=IpPingmodEdit.aliveIp[i];//now aliveIp2 contains the list of IP addresses which are alive;
	System.out.println(IpPingmodEdit.aliveIp2[i]);
}

}

try {
			System.out.print ( "\007" );
			System.out.flush(); 
			Ping25.beep=true;
		} catch (Exception e) {
			e.printStackTrace();
		}

if(Ping25.beep==true)
IpPingmodEdit.scan_fin=true;



} //run completes
}
//class 25 ends
*/

I need to display the gif image"Please wait while scanning hosts"
as soon as i click the button 'Scan'

I haven't gone through the entire program of yours, no need to even, since there is much of repeatition. But what I have gathered from a quick look is that you need to avoid making all those classes. You are doing the same thing in all of them. Why not then make 25 instances (threads) of the same class. You can pass a parameter to the thread specifying the IP range it needs to scan.

I haven't gone through the entire program of yours, no need to even, since there is much of repeatition. But what I have gathered from a quick look is that you need to avoid making all those classes. You are doing the same thing in all of them. Why not then make 25 instances (threads) of the same class. You can pass a parameter to the thread specifying the IP range it needs to scan.

Um, all those classes have been replaced with a single "parametrisised" class, now. ;-)

I still don't agree with the approach though.

Personally, I would use 20 threads and the "isReachable()" method.

Edit: That's if I were forced to do it. Personally I wouldn't do it at all, but hey, he's probably got his reasons, and they may even be good ones.

Edit Again: @OP I have not looked at the "video", and probably never will. Don't mean to be mean, but it is, at the moment, too much involvment for me at the moment to go through all that. I can only assume that it has, at least partially, to do with the fact that you are doing a good amount of work on the event thread, and I still don't see where you are starting threads for the purpose of reading the output and error stream of the started processes, so it is still very much possible that a buffer is filling up.

@masijade : Yeah you might be correct on this, cause you seem to have had a better look at his code. For me I just gave it a glancing look and suggested him the most outrightly wrong thing that appeared to me. Actually ain't able to take much time out. Also since his code post was huge, I just hurriedly scrolled down through it, without even realizing that you had already made the same suggestion (and more) to him. It's just today when I saw the number of replies to it and carefully scrolled for more replies that I saw your first post on this.

@masijade i tried to use the isReachable method,it sends an echo_request to port 7 i guess on machines.and on most windows machines all request are blocked ,so no use for me,
So i tried this alternate approach,using cmd commands and now i m not facing the buffer problem with my code now,i am attaching the new code with two new code files jMenu.java and IpPingmodEdit.java in the attachments,
The Big problem now:The Event Code runs Twice,i.e the MousePressed.I dont find a reason why

public void mousePressed(MouseEvent me)

is called twice,please help me with this,my job is almost done.:)

Thanks so much for your help both of you,i now marking the thread as solved,Thank you so much

i tried to use the isReachable method,it sends an echo_request to port 7 i guess on machines.and on most windows machines all request are blocked

The Echo server runs on port 7 which just echoes back to you whatever you send to it. The reason on most servers you would find this blocked is security.
You can read this post and the post below it which explains this.

It does an echo request on port 7 for users without "adminstrator" rights. If the user has adminstrator rights it does something else (although I don't remember, off-hand, exactly what).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.