Environment variables and system properties
On This Lesson 4 topics
The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.
In this lesson
override settings from outside.
Planned topics
- Environment variables are set by the operating system or container:
System.getenv("SHOP_TAX_RATE"). - System properties are set when starting Java:
-Dshop.tax-rate=0.07; read withSystem.getProperty. - Names are usually UPPER_SNAKE_CASE for environment variables.
- Common pattern: file gives defaults, environment overrides.
- Convert types yourself and fail clearly on bad values.
Draft outline details
Demonstration
String rate = System.getenv().getOrDefault("SHOP_TAX_RATE", props.getProperty("shop.tax-rate"));Check your understanding
How do you pass a system property?
Show answer
With -Dname=value on the java command.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.