Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • So this is just for windows? Is there a platform independent way to do this? Commented Sep 24, 2012 at 13:25
  • 8
    System properties are not environment variables. Use System.getenv("USER") for environment variables. System.properties can still be set by user on java commandline with java -Duser.name=someoneelse so still not secure Commented Aug 23, 2013 at 2:51
  • "There are similar methods for unix based OS as well": Thanks, what i was looklng for. So what is the method for these OS? my research, currently conducted me ... here :) using "whoami" ? Commented Aug 26, 2016 at 8:02
  • What is "secure" methods that cannot be faked? Is it exists? Commented Nov 20, 2023 at 1:56