Setting global environment variables are OS specific, and are essentially managed by the OS itself. The OS is responsible for passing on the default environment values to new process spaces.
Therefore you will want to refer to your Operating system's requirements.
In Windows it is stored in the system registry. To access it from the command line you can use SETX or if you are including use the Windows API to access HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment or HKEY_CURRENT_USER\Environment.
In Linux it can be distribution specific, but at least in Ubuntu the environment is configured in the ~/.profile file.