此代码无法使用lein compile
进行编译。重要的部分是gen-class
和-main
函数。代码使用JavaFX 8和Clojure 1.7,但这些只是细节。我的问题是关于AOT编译以及如何引用生成的类。
(ns the.app
(:import
[javafx.application Application]
[javafx.scene Scene]
[javafx.scene.layout StackPane]
[javafx.stage Stage])
(:gen-class
:name the.app.App
:extends javafx.application.Application
:main true))
(defn start
[^Application app
^Stage stage
{:keys [width height title] :as opts}]
(let [root (StackPane.)
scene (Scene. root width height)]
(if title (.setTitle stage title))
(.setScene stage scene)
(.show stage)))
(defn -start
[app stage]
(start app stage {:title "App" :width 800 :height 600}))
(defn -stop
[app]
(println "-stop"))
(defn -main
[& args]
(Application/launch the.app.App args))
我的project.clj
包含:
:dependencies [[org.clojure/clojure "1.7.0-alpha4"]]
:aot [the.app]
:main the.app
错误消息是:
Caused by: java.lang.ClassNotFoundException: the.app.App
我原以为编译会创建the.app.App
。如何解决引用课程compiled from AOT的问题?