Search code examples
clojureclojurescriptleiningenclojure-java-interopfigwheel

How to compile and import Java class with lein-figwheel?


I added :java-source-paths ["src/java"] to my project.clj, lein uberjar works but when running lein figwheel I get the following error:

Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid :)
java.lang.ClassNotFoundException: projectc.java.gcloud.DataStore, compiling:(projectc/gcloud/datastore.clj:1:1)

I added this to the ':uberjar` section

:prep-tasks ["javac" "compile" ["cljsbuild" "once" "min"]]

Any clues to how to solve this?


Solution

  • When Figwheel (and the ClojureScript compiler) compiles your code, it will process all clj files that it is given, to compile macros that are in clj files. It looks like Figwheel is trying to compile a file which is using a class which isn't on the Classpath? Is it possible to include that class, or exclude the Clojure file from the Figwheel compilation? Perhaps try building that Java project as a JAR and including it as a dependency as a test?

    It's a little hard to tell with not very much information, this issue also looks like it might be relevant?