The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Java


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.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 10-28-2007, 01:29 AM
zaher1988 zaher1988 is offline
Novice
Join Date: Oct 2007
Posts: 11
iTrader: (0)
zaher1988 is on a distinguished road
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?

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 10-28-2007, 12:05 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Get local machine ip using JavaScript

I posted it there

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 10-28-2007, 12:18 PM
zaher1988 zaher1988 is offline
Novice
Join Date: Oct 2007
Posts: 11
iTrader: (0)
zaher1988 is on a distinguished road
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

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #4 (permalink)  
Old 10-28-2007, 02:20 PM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 615
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
I am guessing the first half but getHostName() should be right?:
localhostname = java . net . InetAddress . getHostName ();

Not sure about the other.

If a posts been useful dont forget to click "Thanks".

Lee.
Reply With Quote
The Following User Says Thank You to Lee For This Useful Post:
HelloWorld (10-28-2007)
  #5 (permalink)  
Old 10-28-2007, 02:28 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
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..

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #6 (permalink)  
Old 10-28-2007, 02:37 PM
zaher1988 zaher1988 is offline
Novice
Join Date: Oct 2007
Posts: 11
iTrader: (0)
zaher1988 is on a distinguished road
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:
  1. Machine name
  2. Logged in username
  3. OS running on machine
  4. Country set for machine
  5. User home directory
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");
     }
}

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to zaher1988 For This Useful Post:
HelloWorld (10-28-2007)
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 04:15 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50