473,503 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get host name that run applet

37 New Member
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 9371
madhoriya22
252 Contributor
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 Recognized Expert Specialist
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 New Member
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
2277
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
3323
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
4361
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
3450
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
1666
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
2653
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
1282
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
4749
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
29439
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
7202
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
7280
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
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.