Is it possible to get the name of the currently logged in user (windowsWindows/unixUnix) and the hostname of the machine.?
I assume it's just a property of some static environment class.
I've found this for the user name
com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); and this for the machine name:
import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } Is the first one just for windowsWindows?
andAnd what will the second one do, if you dontdon't have a hostname set?