B4J Library NHEnvironentVariables - Get a map with all environment variables of a Linux Distribution - Does not break in Windows and MacOS

With this library you can get a map with all environment variables of a Linux Distribution. 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

  • NHEnvironmentVariables.zip
    3 KB · Views: 37
Last edited:
Top