Thursday, December 15, 2011

How to find the current logged in windows user from java?


The class NTSystem will help to retrieve the logged in user name and other credentials.

Example:

NTSystem obj = new NTSystem();
System.out.println("Logged In User Name "+obj.getName());


From the java docs :-


This class implementation retrieves and makes available NT security information for the current user.

http://docs.oracle.com/javase/6/docs/jre/api/security/jaas/spec/index.html?com/sun/security/auth/module/package-summary.html