How can I obtain the physical machine name that my jvm is running in?
(Physical = OS, up to vmware...)
Added from poster's comment:
I mean the name of the computer the JVM is running in. Most likely a physical computer, but if the JVM is running inside another virtual machine then that name is good.
We can get the System name for a Windows or Linux machine using the getHostName() method of the InetAddress class of java.net package after getting the IP address of the system using getLocalHost() method of the same class. The class InetAddress gets the IP address of any hostname.
In Java, you can use InetAddress. getLocalHost() to get the Ip Address of the current Server running the Java app and InetAddress. getHostName() to get Hostname of the current Server name.
String computername=InetAddress.getLocalHost().getHostName(); System.out.println(computername);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With