Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Advance Java Program Microproject

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

P K TECHNICAL CAMPUS,CHAKAN

A MICRO-PROJECT REPORT ON

“PREPARE IP ADDRESS USING SWING”

SUBMITED BY

Avishkar Khenat

UNDER GUIDANCE
Prof Mrs. ANKITA GADEKAR
P K TECHNICAL CAMPUS,CHAKAN

THIS IS CERTIFY THAT THE MICROPROJECT


IS SUCCESSFULLY SUBMITTED BY,

Avishkar Khenat

MRS.ANKITA GADEKAR HOD


❖Introduction
An IP address (Internet Protocol) is an identifier allocated to each
computer and another device (like a router, mobile, etc.) connected
to a TCP/IP network that we use to locate and determine the node
in communication with other nodes on the network. IP addresses
are generally written and displayed in human-readable notation,
such as 192.168.1.03 in IPv4(32-bit IP address).
An IP address performs two principal functions: host or network
interface identification and local addressing. We can characterize its
role as follows: “A name means what we seek. An address indicates
where it is. A route shows how to get there.”

❖ IP Finder in Java
To create IP Finder in Java with the help of Networking, AWT/Swing
with event handling to avoid errors in the code. Let's see the
implementation for creating IP Finder in Java.
String url = "www.cogingninjas.com";
InetAddress iadds = InetAddress.getByName(url);
String ip = iadds.getHostAddress();

You can also try this code with Online Java Compiler

❖Run Code
• Working Example
Here is an example to demonstrate the working of IP Finder in Java.
It is implemented using java Swing.

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

public class IPFinder extends JFrame implements


ActionListener {
JLabel l;
JTextField text;
JButton b;

IPFinder() {
super("IP Finder - Coging Ninjas");
l = new JLabel("Enter URL:");
l.setBounds(50, 70, 150, 20);

text = new JTextField();


text.setBounds(50, 100, 200, 20);

b = new JButton("Find IP");


b.setBounds(50, 150, 80, 30);
b.addActionListener(this);
add(l);
add(text);
add(b);
setSize(350, 350);
setLayout(null);
setVisible(true);
}

public void actionPerformed(ActionEvent e) {


String url = text.getText();
try {
InetAddress iadds = InetAddress.getByName(url);
String ip = iadds.getHostAddress();
JOptionPane.showMessageDialog(this, ip);
} catch (UnknownHostException e1) {
JOptionPane.showMessageDialog(this,
e1.toString());
}
}

public static void main(String[] args) {


new IPFinder();
}
}
You can also try this code with Online Java Compiler

❖ Run Code

Output
• Frequently Asked Questions
➢What is an IP address in Java?
The IP address is a 32-bit or 128-bit unsigned number used by the
IP, a lower-level protocol on which protocols like UDP & TCP are
built. The InetAddress class represents an IP(Internet Protocol)
address in Java.

➢How do I find the IP address of a link?


The most direct way to find the IP address of a website is to use our
DNS Lookup Tool. Go to the DNS Lookup Tool, type the website URL
into the text entry, and select Lookup. The search yielded an array
of IPv4 addresses that differ from the IPs displayed using the other
methods.

➢What's the IP of a website?


An IP address is a string of numbers divided by periods that acts as
a unique identifier for gadgets on the internet or a local network. IP
or "Internet Protocol" is the set of rules governing the format of
data sent via the internet or a local network.
➢ Can websites see your IP address?
Websites can't trace unique IP addresses to your physical home or
business address. Rather, websites can tie your IP address to your
internet service provider, city, region, and even your ZIP code.
That's why you see ads for local businesses online.
➢ Can you hack a computer with an IP address?
The internet uses ports & your IP address to connect. Since there
are thousands of ports for every IP address, a hacker having your IP
can try all the ports to brute-force a connection, taking over your
device and stealing your information.
Conclusion
This article gives information on the IP Finder in Java. We see how
one can use IP Finder in Java and find the IP address of any
computer.

You might also like