How To Make IP Finder In Java With Source Code

This tutorial is about how to make IP Finder in java with source code. By following this tutorial you can able to make a software for finding your IP Address with Java programs codes.
Read Also:
1. Games With JavaScript Codes: Make A Snake Game With Notepad
2. Create Youtube like Rating with Jquery and Ajax
3. Top Java Software Errors: 50 Common Java Errors and How to Avoid Them

After finished your programs in Java with below codes, you will able to see this image like screenshot appear.
Make IP Finder In Java With Source Code

IP Finder in java with source code

You just copy these source code from below and make a soft with Java for finding IP address. When you are done then you just input a web address and press enter. You will see your IP Address which I provide as a screenshot before.
String url="www.javatpoint.com";  InetAddress ia=InetAddress.getByName(url);  String ip=ia.getHostAddress();  
Now let's see the Swing code below to find IP address;

import javax.swing.*;
import java.awt.event.*;
import java.net.*;
public class IPFinder extends JFrame implements ActionListener{
    JLabel l;
    JTextField tf;
    JButton b;
IPFinder(){
    super("IP Finder Tool - Javatpoint");
    l=new JLabel("Enter URL:");
    l.setBounds(50,70,150,20);;
    tf=new JTextField();
    tf.setBounds(50,100,200,20);
     
    b=new JButton("Find IP");
    b.setBounds(50,150,80,30);
    b.addActionListener(this);
    add(l);
    add(tf);
    add(b);
    setSize(300,300);
    setLayout(null);
    setVisible(true);
}
public void actionPerformed(ActionEvent e){
    String url=tf.getText();
    try {
        InetAddress ia=InetAddress.getByName(url);
        String ip=ia.getHostAddress();
        JOptionPane.showMessageDialog(this,ip);
    } catch (UnknownHostException e1) {
        JOptionPane.showMessageDialog(this,e1.toString());
    }
}
public static void main(String[] args) {
    new IPFinder();
}
}  
If you have any problem in these codes must knock me via the comment section. I will try to solve it. It is helpful? If yes! Don't forget to share with buddies in social media.

About luthfar rahman

I am Luthfar Rahman is the founder of Megaupdate24. I am a Computer Science Engineer, Online Marketer, and Public Speaker. Like to traveling and have been blogging last 7 years. Follow me on Facebook, Google+ and Twitter.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment