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.


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.