The question is published on by Tutorial Guruji team.
If I run a Java process as background service then
System.getProperty("user.name") returns ever the hostname with an additional $ character.
Is there a solution to get the real user name of the process which I can see in the Windows task manager?
You can obtain the user who owns the current Java process using
ProcessHandle.current().info().user().get(). It should be the same information provided by the system’s task list.
The documentation for ProcessHandle is here.