lein自定义java类未找到异常

时间:2016-12-15 06:36:41

标签: java clojure classpath leiningen

当我在我的clojure项目中导入自定义java类时,我得到 java.lang.RuntimeException: Unable to stop activity {com.example.android/com.example.MainActivity}: java.lang.IllegalStateException: Activity has been destroyed at android.app.ActivityThread.handleSleeping(ActivityThread.java:3581) at android.app.ActivityThread.access$3000(ActivityThread.java:166) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5590) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1280) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1096) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalStateException: Activity has been destroyed at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1549) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:654) at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:625) at android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:199) at android.support.v4.app.DialogFragment.dismissAllowingStateLoss(DialogFragment.java:177) at com.pugmrks.app.android.MainActivity.onStop(MainActivity.java:918) at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1219) at android.app.Activity.performStop(Activity.java:5592) at android.app.ActivityThread.handleSleeping(ActivityThread.java:3578) ... 10 more

ClassNotFoundException

当我运行;project.clj (defproject subclass "0.1.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.8.0"]] :java-source-paths ["src/java"] :main subclass.core :aot [subclass.core] :target-path "target/%s" :profiles {:uberjar {:aot :all}}) ;src/subclass/core.clj (ns subclass.core (:gen-class :extends BaseClass :exposes-methods {greet pgreet}) (:import BaseClass)) ;This is being qualified as java.lang.BaseClass (defn -main [& args]) //src/java/BaseClass.java public class BaseClass { public String greet() { return "Hello from BaseClass"; } } 时,我收到以下错误:

lein repl

Compiling subclass.core java.lang.ClassNotFoundException: java.lang.BaseClass, compiling:(subclass/core.clj:1:1) Exception in thread "main" java.lang.ClassNotFoundException: java.lang.BaseClass, compiling:(subclas s/core.clj:1:1) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6875) at clojure.lang.Compiler.analyze(Compiler.java:6669) at clojure.lang.Compiler.analyze(Compiler.java:6625) ... snip ... at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.ClassNotFoundException: java.lang.Baseclass at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69) ... snip ... ... 54 more Compilation failed: Subprocess failed 的合格资格为BaseClasss,但失败了。如何从java.lang.BaseClass引用BaseClass?感谢。

1 个答案:

答案 0 :(得分:1)

尝试将BaseClass放入包中。 Java& Clojure不喜欢"裸体"类。