This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get the currently logged user(urgent)

 
netharam ram
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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.
 
BJ Grau
Ranch Hand
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works for me on Win2K:
System.getProperty("user.name")
 
netharam ram
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jim,but I just wanted the system to return "Guest", instead of the username.Anyhow thank you so much.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic