Q:

Java System Environment Variable Current User

What is the best way to get the current logged in user through Java application running on JBoss. The system environment variable System.getProperty("user.name") does not work as JBoss is running as a service.
The application is running on a laptop running Windows XP. The application is web-based and accessed using Internet Explorer by particular logged in Windows user. Only 1 Windows user can be logged in at a time. The application needs to know which user has logged in to do a role based menu and security features. So both the client (Internet Explorer) and the server (JBoss) are running on the same laptop. Currently, we determine the logged in user using tasklist /v and then parsing the output to look for certain processes and the user running them. However, need to know if there is a cleaner way of getting the logged in Windows user.

A:

I don't think the question really makes much sense. There may be no users logged onto the host - or there may be multiple users.
I'd be somewhat wary of a design that really wanted to know this anyway - web applications shouldn't really be interested in that sort of thing, IMO. What are you trying to do?

A:

String uname = System.getenv("user.name")
Reference: http://download.oracle.com/javase/tutorial/essential/environment/sysprop.html

