A Clojure program to demonstrate how to save simple configuration data between program sessions.

The demonstration consists of a program that will save and restore the location and size of the program window across program sessions.

For simple configuration data, Clojure maps, with their key-value pairs, are an obvious choice for data representation. The program saves and restores configuration to a disk file as a map. Note that the EDN library is used to minimize the opportunity for a maliciously constructed configuration file to execute arbitrary code.

The program operates by hooking into the JavaFX start-up and shutdown processes. On shutdown, it saves relevant configuration to disk. During start-up, it retrieves that information. On the first execution of the program, or in the event that the configuration file has been deleted, reasonable default settings are provided.


After downloading the contents of the repository, from within the project directory, run

lein deps

to obtain the program dependencies (just Clojure 1.5.1).

Edit the project file, project.clj, to assure that the :resource-paths item points to the location of the JavaFX runtime library file, jfxrt.jar.

Run the program by executing the following from the project directory.

lein run

The first time the program is run, it will use a default location based on the resolution of your screen.

Move and resize the program window, then exit the program.

Re-start the program and the program window will be displayed at the same location and size as when you closed the program.


Copyright © 2013 David D. Clark

Distributed under the Eclipse Public License, the same as Clojure.