Some Practical Clojure Examples
← prev | next →     Top-level ToC     /properties.html     (printable version)

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 "")
(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 -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 -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.

3 See Also