2014-12-30 4 views
1

이 코드는 lein compile으로 컴파일되지 않습니다. 중요한 부분은 gen-class-main 기능입니다. 이 코드는 JavaFX 8과 Clojure 1.7을 사용합니다. 그러나 이것은 단지 세부 사항입니다. 내 질문에 대한 AOT 컴파일 및 생성 된 클래스를 참조하는 방법에 대한 것입니다.Alo 컴파일에서 Clojure 생성 클래스를 참조 하시겠습니까?

(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을 참조하는 문제를 어떻게 해결할 수 있습니까?

답변

1

나는 resolve 작품을 사용하여 (대신 직접 클래스를 참조) 것으로 나타났습니다 :

(defn -main 
    [& args] 
    (Application/launch (resolve 'the.app.App) args)) 

the.app.Appdefn 형태 evaluated 때 존재하지 않는다는 것을 의미합니다. 클래스는 런타임에 존재해야하며 AOT 컴파일 후에 발생합니다.

관련 문제