This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-13
Channels
- # beginners (18)
- # calva (6)
- # cider (9)
- # clara (1)
- # cljdoc (14)
- # clojure (25)
- # clojure-boston (4)
- # clojure-brasil (3)
- # clojure-czech (2)
- # clojure-italy (2)
- # clojure-sweden (6)
- # clojurescript (6)
- # cursive (6)
- # data-science (4)
- # datomic (2)
- # emacs (5)
- # fulcro (2)
- # kaocha (4)
- # off-topic (2)
- # other-languages (1)
- # pathom (5)
- # precept (1)
- # reagent (2)
- # reitit (1)
- # shadow-cljs (2)
- # spacemacs (49)
- # tools-deps (13)
- # vim (14)
- # xtdb (4)
I believe the answer is that you can have Java source files, but deps.edn isn't intended to do anything with them.
so I just put them in the src/ folder and they'll get picked up by an (import) statement?
Something (other than the clj
or clojure
commands) is welcome to compile Java source files to .class and/or .jar files that can be on a classpath directory specified in a deps.edn file, but having such source files around does not cause clj
or clojure
commands to compile them.
You should use some other tool to cause Java source files to be compiled.
oh I see, that clears things up - so I'll need to compile a .jar
file and refer to it using a :local/root dep
That is one way, yes.
Just to confirm, does that work with interactive development - if I recompile the jar and refresh the clojure ns in the REPL, will the updated classes be imported?
I have not tried, but I would guess no, with the default choice of JVM class loaders used by Clojure. Maybe there is a way using non-default classloaders to make something like that happen, but I have never done it, and I could be wrong in guessing that it is even possible. You would likely be asking for additional headaches by attempting to do so.
If you like the idea of diving in and seeing if you can make it work, this StackOverflow was an early hit I found for Google search terms: "java reload class from jar" https://stackoverflow.com/questions/728140/can-i-dynamically-unload-and-reload-other-versions-of-the-same-jar
But I would strongly caution you that without more expert help than me (or perhaps you have already done similar things before), you could be in for a lot of confusing debugging and frustration there.