Different operating systems use different methods of storing parameter and
configuring data for programs. This list of parameters, usually including PATH
and CLASSPATH, is called the set environment.
-
Windows 95 controls the environment with SET PATH= in autoexec.bat.
-
Linux controls the environment with export PATH= in
your .bashrc file.
-
For NT, since there is no autoexec.bat, you have to preload the environment
strings into the environment with Start | Settings control panel |
system | environment. You can use traditional BAT files to create them,
then echo, copy and paste them into the permanent environment. Remember to click set
before you click OK or your new settings will be
discarded. Also remember to enclose any filenames containing blanks in quotes e.g.
"e:\program files\gnu\wincvs 1.1".
Alternatively always install your apps in directories without embedded spaces.
The control panel uses a microscopic unreadable font. To proofread, copy/paste
to an editor. Beware of spurious spaces introduced by copy/pasting.
-
For the Mac, I don't know how it works. I am told you use JBindery pre Mac OS X
and use normal Unix export in Mac OS X. Sorry I can give you no more detail than
that.
Windows Environment
Windows uses a region called the SET ENVIRONMENT where
you can place configuring information for programs. It needs to be a decently
large size to work with complex programs. If you get out of environment
messages you must modify your C:\config.sys file. Look
for a line in it like this:
shell=c:\windows\command.com c: /u:255 /e:16384 /p
If you find it, make it look exactly like that. If don't see it, add it. You
will need to use a text editor such as NOTEPAD to make
the change. The /e:17374 specifies the desired size of
the set environment in bytes. Make sure there exists a file called: c:\windows\command.com.
If not look for one in c:\ and copy it over.
Here is how to set up your config.sys if you use 4DOS.
shell=c:\4dos601\4dos.com c:\4dos601\ /e:1900 /p
NT Environment
With NT, you don't need to do this since the environment automatically expands
as needed. Further, there is no config.sys or autoexec.bat
file in NT.
You can export the NT/W2K/XP set parameters from the registry two ways that don't
require JNI:
Environment Accessing Kludges
Because some platforms such as the Mac don't have a SET environment, Java does
not support access to it. There are several kludges to query it.
-
Use JNI JNI to poke or peek at the environment in a
platform specific way. Remember than some platforms, e.g. Apple Mac don't have
an environment. You would have to simulate it with a file.
-
exec set xxx and echo
%xxx% commands. Beware, all changes to the SET environment are lost as
soon as your child task exits.
-
Use JConfig.
-
Use properties.
-
use the java.exe -d%flavour% gambit to transfer data
from the set environment to a Java property.
-
Echo the results of set to a env.txt
file before your program starts, or in an exec.