Home > Java > javaTutorial > What\'s the Difference Between Java System Properties and Environment Variables?

What\'s the Difference Between Java System Properties and Environment Variables?

DDD
Release: 2024-11-16 12:17:03
Original
621 people have browsed it

What's the Difference Between Java System Properties and Environment Variables?

Java System Properties vs Environment Variables in a JVM

Question:

In a Java Virtual Machine (JVM), what distinguishes system properties obtained through System.getProperties() and environment variables retrieved using System.getenv()?

Answer:

System Properties:

  • Set on the Java command line using -Dpropertyname=value.
  • Can be modified at runtime using System.setProperty() or System.getProperties().load() methods.
  • Retrieved using System.getProperty(String key) or System.getProperty(String key, String def).

Environment Variables:

  • Set in the operating system environment.
  • Not modifiable at runtime.
  • Accessible through System.getenv(String name).

The above is the detailed content of What\'s the Difference Between Java System Properties and Environment Variables?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template