Use a JAVA program to obtain the IP address-general Linux technology-Linux programming and kernel information. The following is a detailed description. When using the TCP/IP Internet, you often need to query the IP address of your host and the IP address of the www server. Although we can use IPCONFIG and PING to Query IP addresses, if we use this command in an application or APPLET, we will destroy our application interface.
Therefore, a simple program using JAVA can directly query the IP address of the host and the IP address of the www server.
// The file name is NetTool. java.
(Note: In the JAVA language, uppercase and lowercase are sensitive)
Import java.net .*;
Public class NetTool {InetAddress myIPaddress = null;
Because of the cross-platform features of JAVA, the above programs can be directly run on any machine with a JVM system installed after compilation. The above program aims to inspire you to convert the above Code into an APPLET and add it to your homepage, or write the address query result to a file to create your own local hosts file.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.