Martin Kavalar / Jun 20 2019
Remix of Clojure by Nextjournal

Clojure + Cljfx

Remix this to get started with Clojure and Cljfx. See the section below for how this sets up JDK 11. This notebook is using a custom environment (see Setup below) as well as a GPU, so it takes about two minutes to boot.

(require '[cljfx.api :as fx])

Here's hello world.

@(fx/on-fx-thread
  (fx/create-component
    {:fx/type :stage
     :showing true
     :title "Cljfx example"
     :width 300
     :height 100
     :scene {:fx/type :scene
             :root {:fx/type :v-box
                    :alignment :center
                    :children [{:fx/type :label
                                :text "Hello world"}]}}}))

Environment Setup

Because Cljfx requires Java11+ and our default Clojure environment is von JDK 8, we need to import the environment from docker hub.

OpenJDK+Clojure
Download as Docker image from:
Copy
This image was imported from: clojure:openjdk-11-tools-deps

Then we also need to install libopenjfx-jni. Note that these cells are locked to avoid accidental changes.

apt-get install -qq libopenjfx-jni

This deps.edn is being mounted to /root/.clojure/deps.edn.

{:deps
 {org.clojure/clojure {:mvn/version "1.10.0"}
  cljfx {:mvn/version "1.3.3"}}}
deps.edn
Extensible Data Notation

Let's invoke clj to download the libraries upfront.

clj -Spath