|
Prev: Non-verbose, simple way of getting pixels of an image?
Next: Escape characters output by JSON Array?
From: Martin Gregorie on 14 Jul 2008 14:58 On Mon, 14 Jul 2008 11:13:35 +0000, Stefan Ram wrote: > I also would like to know what this program prints on other > systems (especially on a Linux System, but also different > variants of Windows), but feel free to remove parts of the > output to protect privacy or security. > Here you go: $ java Main os.name = Linux os.version = 2.6.25.9-40.fc8 # I'm running RedHat Fedora 8 java.home = /home/java/jdk1.6.0_05/jre # with Sun JDK 1.6.05 user.home = # My login directory when I ran it /home/kiwi user.dir = # My current working directory at the time /home/kiwi/compiler_tests/environ java.io.tmpdir = # default for FC8 /tmp fileSystemView.getDefaultDirectory() = # $HOME (see below) /home/kiwi /home/kiwi fileSystemView.getHomeDirectory() = # $HOME (set when user logged in) /home/kiwi /home/kiwi getCodeSource().getLocation() = # As for user.dir /home/kiwi/compiler_tests/environ /home/kiwi/compiler_tests/environ Linux, like all Unices, has a number of additional defaults at both user and system level that we'd normally expect to be set for the particular host: - $PATH is where the OS looks for executables. It is typically something like: /bin:/usr/bin:/usr/local/bin which are (respectively) where os essentials, programs installed as part of the distro, and locally installed and/or written executables live. '.' (the current dir) isn't on the search path by default but is reasonably commonly added, together directories containing major 3rd party packages such as Oracle. These defaults can be customised at both user and system level. The OS has facilities to make this easier and to let customisations survive OS reinstalls and upgrades. If the user is privileged, e.g. root, they will also have /sbin, /usr/sbin and possibly /usr/local/sbin in $PATH This shouldn't normally concern a Java application but its mentioned for completeness. - unlike Windows, you'd normally expect to find config files for standard packages in /etc and for locally installed/written packages in /usr/local/etc, possibly with user specific configurations in hidden files in $HOME. A 'hidden' file's name starts with '.' and isn't shown in a directory listing or a wild carded list unless explicitly asked for. This gives a little protection against accidental deletion etc. This does have implications for Java apps. You might reasonably expect a configurable Java app to search (in order) the current directory, $HOME, /usr/local/etc and /etc for its config file/properties file and use the first it found. Alternatively, if progressively localised customisations are are to be applied to a default config, it would be reasonable to do the search in the opposite order, and apply all files in the order they are found to build up a final configuration for the current user. I think the way /etc and its siblings is used is the major difference from Windows and its not really portable to another OS, except by coding the search into the app and using the os.name property to determine which search strategy should be used. One other point: many *nix utilities use a config file format that's compatible with a properties file. Comments start with #, individual parameters are written as "name = value". HTH -- martin@ | Martin Gregorie gregorie. | org | Zappa fan & glider pilot |