Hai, I want to know the user who is currently logged in the machine.If possible post the code too,lets consider windows as the O.S.Now I want to get the user from java,where I customize the perferences for my aplication based on the user logged in.
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
<pre> System.out.println(System.getProperty("user.name"));</pre> See the API for System.getProperties() for a list of other proerties you can access. Additional properties may be available on your system - this list is just the standard ones.
"I'm not back." - Bill Harding, Twister
BJ Grau
Ranch Hand
Joined: Jul 10, 2001
Posts: 234
posted
0
This works for me on Win2K: System.getProperty("user.name")
netharam ram
Ranch Hand
Joined: Aug 09, 2001
Posts: 202
posted
0
Hi. it's working fine,but the problem is if the user is a guest it displays unknown.Is there anyway to identify the guest user too.
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
<pre> System.out.println("Who the heck are you?");</pre> Seriously, if the system allows people to log in with no account or password, then you will have to ask them.
netharam ram
Ranch Hand
Joined: Aug 09, 2001
Posts: 202
posted
0
Thank you Jim,but I just wanted the system to return "Guest", instead of the username.Anyhow thank you so much.