Java get windows Username

Ads
 
Tutorials   
How to replace all occurrences of a string in JavaScript? How to convert a stack trace to a string? Example code of reading file line by line in Java with Apache Commons IO library How to store unique values in Java using Set? java.nio ShortBuffer Example How to use Java Path class? Java NIO Package Tutorial How to limit object creation in Java? Java 11 String lines function example to split it in lines Top upcoming features of JDK 11 Java/JDK 11 Tutorial How to install JDK 10 in Ubuntu 18.04? Install JDK 10 on Windows Java 10 features Processing large file in Java Learning Java for non programmers Why You Should Learn Java in 2018? Installing JDK 9 on Windows 10 How to convert binary to decimal in Java? How to add two numbers in Java? What is Applet in Java with Example? What is nested class in Java with Example? Exception handling in Java Programming Examples What is Constructor Overloading in Java? How to display image in Swing? What is Java programming used for? How to create custom exception in Java? How to set CLASSPATH in Java? What is Multithreading in Java? IO Streams in Java with Examples How to convert String Date to Timestamp in Java? Best Java Tutorial for Beginners Read user input in Java using Scanner Java Programming Examples Read file line by line in Java 8 What are the benefits of learning Java Programming? A brief history and future of Java programming language Importance of Java for Mobile Application Development How To Become A Good Software Developer? Learn Java Programming for beginners

Java get windows Username

This page discusses - Java get windows Username

This page discusses - Java get windows Username

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

Ads

Ads