Last active
February 22, 2022 21:28
-
-
Save Kuchitama/4572467 to your computer and use it in GitHub Desktop.
JavaFX + Clojure + leiningen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns kuchitama.javafx | |
(:gen-class | |
:extends javafx.application.Application) | |
(:import [javafx.application Application] | |
[javafx.scene Scene Group] | |
[javafx.stage Stage StageBuilder])) | |
(defn -start [this stage] | |
(let [scene (Scene. (Group.)) | |
builder (doto (StageBuilder/create) | |
(.title "test") | |
(.scene scene) | |
(.x 100) | |
(.y 100) | |
(.width 300) | |
(.height 200) | |
)] | |
(.show (.build builder)))) | |
(defn -main [& args] | |
(Application/launch kuchitama.javafx args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject javafx "0.1.0-SNAPSHOT" | |
:description "Sample Program of JavaFX with Clojure" | |
:dependencies [[org.clojure/clojure "1.4.0"]] | |
:resource-paths ["lib/jfxrt.jar"] | |
:main kuchitama.javafx | |
) |
Include the Gluon JavaFX maven artifacts and then use as usual.
Something like:
[org.openjfx/javafx-base "11.0.2"]
[org.openjfx/javafx-controls "11.0.2"]
[org.openjfx/javafx-graphics "11.0.2"]
[org.openjfx/javafx-swing "11.0.2"]
Note, the *Builder
classes have been removed (a long time ago). This bit me as I had an old project that depended on them and could not find them.
There are Gluon JavaFX maven artifacts for JDK 17 as well. I use JDK 11 for a legacy application because JDK 11 will still be supported for another year and a half or so. Same with the Gluon JavaFX jars.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is outdated. New projects will be using OpenJFX or Oracle's JFX (which is optional and not packaged with JDK). Therefore, the jfxrt.jar no longer exists with Java.
Unfortunately, I still cannot figure out how to get OpenJFX installed in a way that makes sense to me. I'd like to use Maven central to get the jars, but this is failing. So I do not have an alternative working solution yet.