This example show you how to get operating system active user’s login name. We can obtain the username of current user by reading system properties using the user.name key.
package org.kodejava.lang;
public class GettingUserName {
public static void main(String[] args) {
String username = System.getProperty("user.name");
System.out.println("username = " + username);
}
}
Latest posts by Wayan (see all)
- How do I implement the Adapter pattern in Java? - December 4, 2026
- How do I display data in a JTable in Java Swing? - December 4, 2026
- How do I update task completion with state in Jetpack Compose? - December 3, 2026