Subscribe

RSS Feed (xml)

Powered By

Place Your Ads Here

Detecting Host Os and IP Address Using java



I am going to write the code for detecting local pc name and ip address of localpc using java
i have take a java desktop application in netbeans 6.5 having jdk1.6 running on windows vista ultimate..
i have taken a instance varible String Array type s1 initilizing it on jbutton action performed.
as..
s1=new String[] {
java.net.InetAddress.getLocalHost().getCanonicalHostName()
,java.net.InetAddress.getLocalHost().getHostAddress()
,System.getProperty("user.name")
,System.getProperty("os.name")
};



  • java.net.InetAddress.getLocalHost().getCanonicalHostName() It gets your PC name.
  • java.net.InetAddress.getLocalHost().getHostAddress() It gets your Ip address.
  • System.getProperty("user.name") It gets your username.
  • System.getProperty("os.name") It gets your Operating System Name.
Note :-You have to import java.net

you can also download full source code from here
Source Code

0 comments: