Get Name of User Currently Logged In to the Computer in Java

Description

The following code shows how to get Name of User Currently Logged In to the Computer.

Example


/* w ww. ja  v  a2s. co  m*/
public class Main {

  public static void main(String[] args) {
    String currentUser = System.getProperty("user.name");
    System.out.println(currentUser);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization