![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| Retrieve machine local ip Hello I'd like to know if there is any way in Java to retrieve the local ip of a machine browsing a Java applet. I don't want the ip of the http request, i need the local ip that might not even be used for internet. In addition to this, is there also anyway to get the machine name? or the system logged in username of the local machine? |
| |
| |||
| Alright thank you very much, i have check both codes (java and javascript) you have provided in the other thread. One more thing, i need to get the computer name and the logged in username on the machine also in a Java applet. Thank you |
| The Following User Says Thank You to Lee For This Useful Post: | ||
HelloWorld (10-28-2007) | ||
| ||||
| what Lee said is correct, that's the way you get the computer name, I don't think you can get the username of the computer, but you may want to double check on this... I'd say that you can do this if you know the background of the operating system that user is using, Windows or UNIX based.. they're going to be different.. |
| |||
| Thank you for your efforts, well that's not what i wanted, i don't want to use the hostname, i have already tried it with php and such, but they don't get the machine name especially when you are not running a real ip. Anyway i have done some research and i was able to develop this class that retrive you the following:
Code: public class Processes
{
//Retrieve the local machine name
public String getComputerName()
{
return System.getenv().get("COMPUTERNAME");
}
//Retrieve the machine logged in user
public String getComputerUser()
{
return System.getenv().get("USERNAME");
}
//Retrieve the machine's country'
public String getCountry()
{
return System.getProperty("user.country");
}
//Get the OS running on machine
public String getOS()
{
return System.getProperty("os.name");
}
//Get the user home directory
public String getUserHome()
{
return System.getProperty("user.home");
}
} |
| The Following User Says Thank You to zaher1988 For This Useful Post: | ||
HelloWorld (10-28-2007) | ||
![]() |
| Thread Tools | |
| Display Modes | |
| |