Home Java Java-get-example Java get windows Username
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Java get windows Username

Advertisement
In this section, you will learn how to obtain the window's username. We are providing you an example which will obtain the window's username by using the System.getProperty().

Java get windows Username

     

In this section, you will learn how to obtain the window's username. We are providing you an example which will obtain the window's username by using the System.getProperty(). This will provide all the properties of the windows.

System.getProperty("user.name")- This method retrieve the username of the particular system from all the properties of Windows.

 

 

 

Here is the code of GetWindowUsername.java

public class GetWindowUsername {
public static final void main( String args[] ) {
String userName = System.getProperty("user.name");
System.out.println("Window's Username: "+userName);
}
}

Output will be displayed as:

Download Source Code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 1, 2008

Related Tutorials

Ask Questions?    Discuss: Java get windows Username   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
an0maly
May 11, 2012
thumbs down

This is only capable of returning the current user, System.* can not enumerate all Windows users.
an0maly
May 11, 2012
thumbs down

This is only capable of returning the current user, System.* can not enumerate all Windows users.
UnixUser
November 28, 2013
Java get windows Username

Put your code on Unix and run it from Windows. What user's name it will return?
DMCA.com