Java system properties and environment variables

JavaVariablesPropertiesSystemEnvironment

Java Problem Overview


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

Java Solutions


Solution 1 - Java

Solution 2 - Java

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().

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPraveen SripatiView Question on Stackoverflow
Solution 1 - JavaBohemianView Answer on Stackoverflow
Solution 2 - JavaJake DempseyView Answer on Stackoverflow