Top community members
All Wiki Articles Create Wiki Article

Have you ever heard about encyclopedia for code?

What about: Wiki for Code project?

* because I've tried to share code and my solutions on different services and it was removed or I was unwelcomed
   - maybe it wasn't good place, but this one is.

if you think you have solution that can help someone, you are welcome to share this solution - Click here

Java - how to get single system environment variable value by name?

0 contributions
11 points

Java - get single system environment variable value by name - example

This example prints most commonly used system environment variables in java by their name.

import java.util.Map;

public class JavaGetSingleEnvironmentVariablesExample {

    public static void main(String[] args) {
        Map<String, String> env = System.getenv();

        String os = env.get("OS");
        System.out.println(os); // Windows_NT

        String username = env.get("USERNAME");
        System.out.println(username); // seth

        String numberOfProcessors = env.get("NUMBER_OF_PROCESSORS");
        System.out.println(numberOfProcessors); // 4

        String path = env.get("Path");
        // C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Wind ....

        String windir = env.get("windir");
        System.out.println(windir); // C:\Windows

        String processorArchitecture = env.get("PROCESSOR_ARCHITECTURE");
        System.out.println(processorArchitecture); // AMD64

        String systemDrive = env.get("SystemDrive");
        System.out.println(systemDrive); // C:


C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Wind ....


  1. System.getenv() - Java Docs
  2. Environment variable - wiki
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more