473,396 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

get host name that run applet

37
Hi all,

I want to know if there are any way to get host name that run an applet.

e.g : If I run from another computer, it gives the computer name or web name.
Aug 28 '07 #1
3 9365
madhoriya22
252 100+
Hi all,

I want to know if there are any way to get host name that run an applet.

e.g : If I run from another computer, it gives the computer name or web name.
Hi,
I think this will be helpful for u...
Expand|Select|Wrap|Line Numbers
  1.  
  2. System.out.println(System.getProperty ("user.name"));
  3.  
Aug 28 '07 #2
Nepomuk
3,112 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1.  
  2. System.out.println(System.getProperty ("user.name"));
  3.  
That will just give you the username of that computer. I don't think, you can get the Systems name by using System.getProperty(...), as the following code should display all possibilities, which (at least on my computer) do not include the Systems name.
Expand|Select|Wrap|Line Numbers
  1. if (args == null || args.length == 0)
  2. {
  3.     java.util.Enumeration e = System.getProperties().propertyNames();
  4.     while (e.hasMoreElements()) {
  5.         String key = (String)e.nextElement();
  6.         System.out.println(key +"\t : \t"+ System.getProperty(key));
  7.     }
  8. }
  9. else
  10. {
  11.     for (int n = 0; n < args.length; ++ n)
  12.     {
  13.         if (args[n] != null && args[n].length() > 0)
  14.         {
  15.             String p = System.getProperty(args[n]);
  16.             if (p != null)
  17.                 System.out.println(p);
  18.         }
  19.     }
  20. }
  21.  
If you want the actual computers name, try this:
Expand|Select|Wrap|Line Numbers
  1. try {
  2.    java.net.InetAddress i = java.net.InetAddress.getLocalHost();
  3.    System.out.println(i);                  // name and IP address
  4.    System.out.println(i.getHostName());    // name
  5.    System.out.println(i.getHostAddress()); // IP address only
  6.    }
  7. catch(Exception e){e.printStackTrace();}
  8.  
Source: http://www.rgagnon.com/javadetails/java-0390.html
Aug 28 '07 #3
teenIce
37
That will just give you the username of that computer. I don't think, you can get the Systems name by using System.getProperty(...), as the following code should display all possibilities, which (at least on my computer) do not include the Systems name.

Expand|Select|Wrap|Line Numbers
  1. try {
  2.    java.net.InetAddress i = java.net.InetAddress.getLocalHost();
  3.    System.out.println(i);                  // name and IP address
  4.    System.out.println(i.getHostName());    // name
  5.    System.out.println(i.getHostAddress()); // IP address only
  6.    }
  7. catch(Exception e){e.printStackTrace();}
  8.  
thanks...
i try your code and it works.. :)
Aug 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Bilal | last post by:
Hi, I have a web application that operates on several windows. Each window is named win_1, win_2, win_3,... . When I quit a session, I usually loop through all the windows and close one by one. So...
9
by: Jeff | last post by:
Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For example if I type HostName.domain.com in my browser I want to return it exactly as it appears in the location part of the browser...
1
by: Stefan | last post by:
I'm installing Oracle 9ias Release 2 on Windows 2000 Advanced Server. The installation instructions say to specify a fully qualified host name for the machine. What is the definition of fully...
0
by: aj | last post by:
$ db2level DB21085I Instance "dbtest" uses "32" bits and DB2 code release "SQL08015" with level identifier "02060106". Informational tokens are "DB2 v8.1.0.48", "s040212", "MI00069", and FixPak...
0
by: Sharon | last post by:
I need to get the host name of the local PC/Workstation, so I can use the: Dns.GetHostName() or Environment.MachineName What is the difference between the two? when I read the documentation I...
6
by: Brian Henry | last post by:
is there a way to get the host name of someone? like mine is 68-23-123-123-pitt-pa.adelphia.net? Request.UserHostName doesn't seem to return the host name like it states in the documentation,...
4
by: John A Grandy | last post by:
ASP.NET 2.0 IIS 5.5. In code-behind , how to determine the host name of the site ?
2
by: martin lanny | last post by:
Simple network scanner is a part of my dotnet solution. It pings ip addresses in a selected network range and gives me the response time for each computer it finds. Anyhow, I would need to...
3
by: lilly07 | last post by:
I am using following code to find the hostname/dns name of a linux server. (grep {chomp;} system ('hostname -s')); And the name of the server gets printed as XXX. And I am trying assign this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.