Java Program to Determine the Name and Version of the Operating System Last Updated : 22 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The inbuilt System class in Java provides getProperty() method which is used to obtain the properties of the current working operating system. The System class has two versions of getProperty(). Both retrieve the value of the property named in the argument list. Methods: getProperty() version 1getProperty() version 2Version 1: One of the versions of getProperty() method takes a single argument as property and returns a string containing the value of the property. If the property does not exist, this version of getProperty returns null. Syntax: String System.getProperty( String key ) ; Parameter: Key only, which is the property of the operating system. Return Type: Returns a string containing the value of the property.Returns Null if the property does not exist.Version 2: The other version of getProperty() takes two String arguments, the first argument as property and the second argument is a default value to return if the key cannot be found or if it has no value. Syntax: String System.getProperty( String key, String value ) ; Parameter: Key is the property of the operating system.The default value of the key to be specified in case of invalid property. Return Type: Returns a string containing the value of the property.Returns the default value provided as the second argument in case of an invalid system property.Example: To figure out the name and version of the operating system. Java // Java Program to Determine the name // and version of the operating system // Importing all classes of // java.util package import java.util.*; public class GFG { // Getting name of the OS private static final String nameOfOs = System.getProperty("os.name"); // Getting version of the OS private static final String versionOfOS = System.getProperty("sun.arch.data.model"); // Main driver method public static void main(String[] args) { // Printing name of OS System.out.println( "Name of the operating system is " + nameOfOs); // Printing version of the OS System.out.println( "Version of the operating system is " + versionOfOS); } } Output: The above program is compiled and run on terminal and the output is as follows: Comment More infoAdvertise with us Next Article Java Program to Get System IP Address in Windows and Linux Machine P poojavichare1810 Follow Improve Article Tags : Java Java Programs Practice Tags : Java Similar Reads How to get the value of System Property and Environment Variable in Java? How to get the value of Environment variables? The System class in Java provides a method named System.getenv() which can be used to get the value of an environment variable set in the current system. Syntax: public static String getenv(String key); where key is the Environment variable whose values 3 min read How to get the value of System Property and Environment Variable in Java? How to get the value of Environment variables? The System class in Java provides a method named System.getenv() which can be used to get the value of an environment variable set in the current system. Syntax: public static String getenv(String key); where key is the Environment variable whose values 3 min read Java Program to Get System IP Address in Windows and Linux Machine IP Address: An Internet Protocol address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. Packages used: io (input-output): This package provides for system input and output through data streams, serialization, and the fi 2 min read Java Program to Get System Name for Windows and Linux Machine 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. Â getLocalHost() m 1 min read Java Program for Getting System UUID for Linux Machine Universally Unique Identifiers (UUIDs) are also known as Globally Unique Identifier(GUID) which are 128-bit numbers and are unique on all local systems they are created on also UUIDs created among other systems. Java UUID class is a part of java.util package. Java UUID class represents an immutable 4 min read Java Program to Shut Down Computer in Linux In this program, we will shut down the Computer if the operating System is Linux. So, Firstly we will check that the System on which we are running Java Program is Linux or not. If the operating system is not Linux then we would not proceed further and print âUnsupported Operating Systemâ. If it is 2 min read Like