On Mon, 28 Aug 2023 05:24:09 GMT, Arno Zeller <azel...@openjdk.org> wrote:
>> I think you might use System.getProperty("user.name"). But I am not sure >> about domain names of users on Windows. >> I am also not sure why the user name is currently determined by creating a >> file - there might be a reason for this that is not obvious to me. > > It seems that ProcessHandle.info() returns **DOMAIN/USERNAME** on Windows > but System.getProperty("user.name") only the **USERNAME**. > You can get **DOMAIN** and **USERNAME** on **Windows** by calling: > com.sun.security.auth.module.NTSystem NTSystem = new > com.sun.security.auth.module.NTSystem(); > String user = NTSystem.getName(); > String domain = NTSystem.getDomain(); Yes, I think using System.getProperty("user.name") is brittle as well. If we'd use `com.sun.security.auth.module.NTSystem`, we would introduce the dependency to another module - `jdk.security.auth`. Not sure, whether this is a good option. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15222#discussion_r1308412488