Search code examples
javavariablespropertiessystemenvironment

Java system properties and environment variables


What's the difference between system properties System.getProperties() and environment variables System.getenv() in a JVM?


Solution

  • I think the difference between the two boils down to access. Environment variables are accessible by any process and Java system properties are only accessible by the process they are added to.

    Also as Bohemian stated, env variables are set in the OS (however they 'can' be set through Java) and system properties are passed as command line options or set via setProperty().