Difference between System.getenv() & System.getProperty() [duplicate]

Solution 1:

System.getenv gets an environment variable. System.getProperty gets a Java property. Environment variables are specified at the OS level. Java properties are specified by passing the -D option to the JVM (and can be set programmatically).

Solution 2:

System.getenv() is for Operating System environment variables, whereas System.getProperty() is for JVM arguments which are passed as -DpropName=value to Java application launcher (java).