Browse Prior Art Database

Java-Based System Environment Variable Detector

IP.com Disclosure Number: IPCOM000030257D
Original Publication Date: 2004-Aug-03
Included in the Prior Art Database: 2004-Aug-03
Document File: 2 page(s) / 73K

Publishing Venue

IBM

Abstract

A program is disclosed that retrieves system environment variables that are set and returns those key/value pairs in a Java(tm) HashMap for use in Java(tm) applications. The variables retrieved pertain to those that are accessible by the current user.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 97% of the total text.

Page 1 of 2

Java-Based System Environment Variable Detector

A Java install program will call the EnvironmentVariableDetector.loadEnv() api which returns a Map of key/value pairs. No object instantiation of the EnvironmentVariableDetector object is needed, so only one additional line of Java code is required within the installation program's install code. Below are the tasks that occur within the EnvironmentVariableDetector object upon the invocation of the loadEnv() api (and Figure 1 to show the code flow).

Provides one public static API 'entry point' that requires no arguments. This API should be

static so instantiation of this environment helper object is not needed. No arguments are required for the API. [ie. public static Map loadEnv();] Sets up a command script that will print out the local environment variables to standard

output. This script should be placed in a directory for which the application has write access [ie. System.getProperty("java.io.tmpdir");]; Via the Java Runtime object, the application invokes the command script, and captures the


1.


2.


3.


4.

standard output. Parses the standard output for key/value pairs and places them into a HashMap.


5.

Figure 1.

Returns the Map to the requesting Java application

1

Page 2 of 2

java.io.tmpdir
located

native script

to print env

created

permissions
adjusted on

script as
needed

script invoked
and output is

captured

  output parsed
into key/value
pairs and stored
in a
Java Hashmap

)(nvEdalo

Map of key

/value pairs

Java

Applicatio...