Is is possible to get the name of the currently logged in user (windows/unix) 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 windows?
and what will the 2nd one do if you dont have a hostname set?