B4J Library NHEnvironentVariables - Get a map with all environment variables of all platforms - As of 20250124

(20250124) - Added the same functionality for all platforms. Now you can do the same for Windows and mac.

With this library you can get a map with all environment variables of a Linux Distribution all platforms (Windows, Linux, Mac). The keys of the map are the enviroment variable names and the values of the map the corresponding values of the environment variables. The code does not break in Windows and MacOS but it returns an empty map. Usage:

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
    Private env As EnvironmentVariables
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
 
    env.Initialize
    Dim m As Map = env.GetTheEnvironmentVariables
    Log(m)
 
    'HOME = Some environment variable
    Log(m.Get("HOME"))
    Log(GetEnvironmentVariable("HOME", Null))
End Sub
 

Attachments

  • MyLinuxEnvironmentVars.zip
    3.1 KB · Views: 7
Last edited:

hatzisn

Expert
Licensed User
Longtime User
New version of the class in the first post. Now get the environment variables in B4J in all platforms (Windows/Linux/Mac).
 
Top