Friday, September 20, 2019

IP Finder in Java with Source Code

IP Finder in Java with Source Code: We can develop IP Finder in java with the help of Networking, AWT/Swing with event handling. Let's see the code of creating IP Finder in java.
  1. String url="www.javacodeguruji.com";  
  2. InetAddress ia=InetAddress.getByName(url);  
  3. String ip=ia.getHostAddress();  
Let's see the Swing code to find IP address.
  1. import javax.swing.*;  
  2. import java.awt.event.*;  
  3. import java.net.*;  
  4. public class IPFinder extends JFrame implements ActionListener{  
  5.     JLabel l;  
  6.     JTextField tf;  
  7.     JButton b;  
  8. IPFinder(){  
  9.     super("IP Finder Tool - Javatpoint");  
  10.     l=new JLabel("Enter URL:");  
  11.     l.setBounds(50,70,150,20);;  
  12.     tf=new JTextField();  
  13.     tf.setBounds(50,100,200,20);  
  14.       
  15.     b=new JButton("Find IP");  
  16.     b.setBounds(50,150,80,30);  
  17.     b.addActionListener(this);  
  18.     add(l);  
  19.     add(tf);  
  20.     add(b);  
  21.     setSize(300,300);  
  22.     setLayout(null);  
  23.     setVisible(true);  
  24. }  
  25. public void actionPerformed(ActionEvent e){  
  26.     String url=tf.getText();  
  27.     try {  
  28.         InetAddress ia=InetAddress.getByName(url);  
  29.         String ip=ia.getHostAddress();  
  30.         JOptionPane.showMessageDialog(this,ip);  
  31.     } catch (UnknownHostException e1) {  
  32.         JOptionPane.showMessageDialog(this,e1.toString());  
  33.     }  
  34. }  
  35. public static void main(String[] args) {  
  36.     new IPFinder();  
  37. }  
  38. }  

No comments:

Post a Comment

How to DROP SEQUENCE in Oracle?

  Oracle  DROP SEQUENCE   overview The  DROP SEQUENCE  the statement allows you to remove a sequence from the database. Here is the basic sy...