Fork me on GitHub
João Galrito02:11:45

Hi - I have a Java project where I would like to load (and reload) .clj files at runtime. The folder where these files are located can also change at runtime, so I assume I need a ClassLoader


For the folder changing at runtime, yes, you're going to need to construct a classloader with that folder on it, but as far as reloading Clojure files: if you use Clojure's Java API, you can easily get a handle on require and use it with :reload or :reload-all to get Clojure to recompile namespaces from disk.

seancorfield05:11:30 has some examples of using the Java API to dynamically require a namespace.


Oh, any dependencies your Clojure code needs will have to be added to your classpath somehow too. For Clojure itself, you can just make it a dependency of the Java project -- and if you know your Clojure code's dependencies ahead of time, you can also add those to your Java project, but otherwise you'll need something to resolve and fetch those deps for you.


When I was doing that sort of integration into a legacy (non-Clojure) app, I had the program run clojure -Spath and parsed the output to add JARs to the classpath (the act of running clojure -Spath resolves and downloads deps from a deps.edn file -- I was working with actual Clojure projects and calling into them from legacy code). You could always use -Sdeps to provide extra dependencies via the command-line instead of needing deps.edn. And of course that does assume that you'll have the Clojure CLI installed wherever this Java project might run -- which may not be viable for you.

João Galrito12:11:36

Thank you very much, I got it more or less working yesterday, but the dependencies insight is helpful

João Galrito12:11:47

I'll probably just include the dependencies beforehand

João Galrito12:11:57

For my use case I think that works

Pagoda 5B08:11:02

Hello, request for help from anyone using calva on vscode, and has projects not related to clojure... When I fire up the editor (I have multiple projects open), each window starts the calva extension, usually creating local .lsp files too. I would like to avoid this when the project/workspace I'm opening is not related to clojure in any way: is there some configuration to do that? I have to clean up the project from calva conf files to avoid unwillingly add them to the git projects... Thanks for any help


Calva shouldn’t actually activate in a project not related to Clojure… Anyway, I have this in my ~/.gitignore

So then these file don’t litter down the git repos at least.


There is a #calva channel as well, btw. 😃

thanks2 1

Is there a go-to library that Clojurians use to manage scheduled tasks? I'm looking for a Clojure equivalent of, although maybe a bit more lightweight 🙂


Are you meaning, cron-like functionality?


Yeah, more or less.


I've had good success with


there are lots of others out there too


and so on...


Thanks very much.


You're most welcome.


I'm writing data to a firebase db with cljs, but I get a warning about type inference:

Cannot infer target type in expression (. snapshot val)
Does any one have a hint as to what I should do to resolve this?


You need to use a type hint: Googling the error gives this page