gen-class – how it works and how to use it

Clojure runs on the JVM. Sometimes you have to interface to Java libraries (or be interfaced). In such a case one supporting helper is gen-class. However it's use is not straight-forward. So let's gain some understanding in how it works and how to use it.