Get the user nameFrom WikiJava
This article shows two ways to obtain the user name from the system.
the articleTwo methods are shown:
System get propertyString username; username = System.getProperty("user.name") specific for NT systems (Windows)public class Test { public static void main(String args[]) { System.out.println(new com.sun.security.auth.module.NTSystem().getName()); } } Unixpublic class Test { public static void main(String args[]) { System.out.println(new com.sun.security.auth.module.UnixSystem().getUsername()); } } See Also |
