It’s very easy to get the current machine name
and logged in user
using Java.
Get the Currently Logged in User
String username = System.getProperty("user.name");
System.out.println("Username logged in: " + username);
This is also platform-independent.
Get the Hostname of the Machine
java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();
String hostname = localMachine.getHostName();
System.out.println("Hostname of local machine: " + hostname);