You can use "System.getProperty(os.name)". Else if you just say "System.getProperties()", will return you all the system property including OS name.
You can use the following example.
1. To get os name
public class EnvVar {
public static void main(String args[]) {
String s =
System.getProperty("user.name"
System.out.println(s);
}
}
2. To get all the properties
import java.util.Properties;
public class EnvVar {
public static void main(String args[]) {
Properties p = System.getProperties();
p.list(System.out);
}
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.