javawindowsvariablessystem-variable

PATH system variable capitalization in Java


So i went through all kinds of similar questions but couldn‘t find one specifically answering THIS: From what i know, the JAVA_HOME system variable is case-sensitive and should always be capitalized.

But what about the (optional) PATH variable? Should it be capitalized? Always? Does it matter?

Because my System e.g. already has a Path variable, but not capitalized, instead written like here. Should you then use the already existing one or create a capitalized version in addition?

Thanks in advance.


Solution

  • According to Environment Variables in Windows/macOS/Linux PATH, CLASSPATH, JAVA_HOME , environment variables are case-sensitive on Linux and MacOS (and UNIX) but case-insensitive on Windows.

    And here's a Microsoft source for that information: Environment.GetEnvironmentVariable Method:

    "Remarks:

    Environment variable names are case-sensitive on Linux and macOS but are not case-sensitive on Windows."

    Note that this applies to all environment variables, not just PATH, CLASSPATH JAVA_PATH.

    However, on both Linux, MacOS and Windows, it is conventional to use all uppercase when writing environment variable names in scripts, etc.