Properties
John Gabriele
2014-02
You can ask the system for info on a variety of “system properties”, for example:
(System/getProperty "java.version")
(System/getProperty "java.class.path")
(System/getProperty "os.name")
(System/getProperty "os.arch")
For the full list, use System/getProperties
or see the javadocs for java.lang.System.
1 Setting a property of your own
You can set these on the command line
$ java -Dmy.property=77 -jar my-app-0.1.0-standalone.jar
Note, you can set both an env var and a property at the same time:
$ FOO=42 java -Dmy.property=77 -jar my-app-0.1.0-standalone.jar
2 Properties files
In Java-land, properties are often set and stored in .properties files — Java’s version of .conf/.cfg files.
To read a .properties file, see the Clojure Cookbook recipe 4.18.
That said, in Clojure, you’ll likely prefer to put any config data like that into some “config.edn” file rather than a property file. See the files and directories doc for an example of how to lead a .edn conf file.