How can I obtain the physical machine name that my jvm is running in?
(Physical = OS, up to vmware...)
How can I obtain the physical machine name that my jvm is running in?
(Physical = OS, up to vmware...)
Take a look at the System class, the one used to do System.out.println, etc...
String computername=InetAddress.getLocalHost().getHostName();
System.out.println(computername);
I'm not exactly sure what you mean by Physical Machine Name. Your comment "(Physical = OS, up to vmware...)" needs explaining to me.
But you can use System.getProperty(String key) where key is one of the keys found here: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()
That should tell you OS name. If you need hostname use jsight's advice.
Couple options, since I'm not sure what you want:
RuntimeMXBean rmx = ManagementFactory.getRunTimeMXBean();
System.out.println(rmx.getName());
Or...
System.out.println(InetAddress.getLocalHost().getHostName());
Or on Linux
Runtime r = Runtime.getRuntime();
Process p = r.exec("uname -a");
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream());
System.out.println(r.readLine());