ADVERTISEMENT
ADVERTISEMENT

Java program to get System Name for Windows or Linux Machine

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);
    }
}

Output

Computer Name : DESKTOP-13DO19X

Java Most Popular & Searched Programs »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.