Capturing username entered on the machine

3

I need to add in my program a method where it will capture the logged-in user of the machine and then display it to the client.

The client will run the program, and then it will show you information about your computer that should include the user logged into the machine.

Is there any way to do it without having to use processBuilder ?

    
asked by anonymous 21.11.2014 / 04:53

1 answer

4

One way is with getProperty :

System.getProperty("user.name")

You can pick up a lot of useful information with it about the JRE and the operating system.

The other existing forms are not recommended. In general this resolves.

    
21.11.2014 / 05:10