Get System Name of Linux or Windows based Machine: This java program will get and print the system name of Linux or Windows Operating System based Machine.
package com.includehelp;
import java.net.InetAddress;
/**
* Program to get system Name for windows and Linux Machine
* @author includehelp
*/
public class SystemName {
/**
* Method for Get System Name
* @return System Name
*/
public static String getSystemName(){
try{
String systemName =InetAddress.getLocalHost().getHostName();
return systemName;
}
catch(Exception E){
System.err.println("System Name Exp : "+E.getMessage());
return null;
}
}
public static void main(String[] args) {
String SystmName = getSystemName();
System.out.println("Computer Name : "+SystmName);
}
}
Get System Name of Linux or Windows based Machine: This java program will get and print the system name of Linux or Windows Operating System based Machine.
Output
need an explanation for this answer? contact us directly to get an explanation for this answer