Environment Variables in CLIPS
Our first program will demonstrate how to work with environment variables in Java. Environment variables are a universal mechanism for conveying configuration information to programs. Let’s look at how to set, get, and list environment variables.
Running the program shows that we pick up the value for FOO
that we set in the program, but that BAR
is null.
Note that System.setProperty()
doesn’t actually modify the system environment variables, it only sets Java system properties. To see the effect of setting an environment variable, you need to set it before running the Java program:
The list of environment variables will depend on your particular machine.
In Java, unlike in some other languages, you cannot modify the environment variables of the currently running process. The System.setProperty()
method sets a Java system property, which is different from an environment variable. If you need to modify environment variables, you typically do so before starting the Java program, or you use system properties as an alternative within your Java application.