473,657 Members | 2,432 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 9382
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.getPrope rty(...), 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.getPrope rty(...), 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
2286
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 far so good until my client wants to surf on 1 particular window and doesn't want that window to close when a I quit a session. I had something in mind: find the window url through "window.location.host" or something (I'd save it as a global...
9
3331
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 "HostName.domain.com" but it keeps returning a case insensitive result "hostname.domain.com".
1
4377
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 qualified host name computername.domain or computername.domain.com....
0
3461
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 "5". Product is installed at "/opt/IBM/db2/V8.1". Red Hat Linux Advanced Server release 2.1 kernel 2.4.9 ------------------------- As part of my transition to DB2 v8, I will: -install the DB2 v8 s/w on an alternate machine (dbtest)
0
1676
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 couldn't decide which one to use. I must say the the PC may not be connected to the Internet/Intranet. Which one should I use? Is there any other way to get the local host name which is better then the above two?
6
2661
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, only gives me back an IP address.. which is what I assumed Request.UserHostAddress would do... they both return the same values all the time
4
1290
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
4759
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 retrieve two more pieces of information for each active (local network) IP address: - Computer's Host Name - Mac Address
3
29571
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 value to $host as below. But it is not working and $host name is null. How do I assign XXX to $host. $host =(grep {chomp;} system ('hostname -s')); print "The host name is $host \n";
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.