tools-deps 2024-04-21

I'm not sure if this is possible, but I want to access a protected field in library. I thought I could add a Java class to my project in the same package and extend the relevant class. Multiple aspects of this idea may be ill conceived, but here's what I did: • Added src/a/b/c/MyClass.java • Set package a.b.c; in it • Defined public class MyClass extends LibraryClass in it • Added a method that does what I want I can start the REPL just fine, but (import 'a.b.c.MyClass) gives me a java.lang.ClassNotFoundException My main question is whether this is the right way to add a Java source to a tools.deps project, but any pointers would be appreciated 🙂

did you compile it? need to run javac manually (e.g. tools.build)

Aha. Where do I want the output class - same directory?

You question led me to https://clojure.org/guides/tools_build#_mixed_java_clojure_build which helps me a little further 👍

yeah java only loads compiled .class files on the classpath

although I believe an upcoming jdk gets support for loading .java files as well IIRC

Yeah, I know, but I was hoping that the Clojure tooling did some magic stuff for me 🤠

lein does 😉

So now I have the class in target/classes. Should I add target to my sources in deps.edn, or is this loaded by default?

target/classes. target alone does nothing useful

Right 😅

Success! Thanks 😊

👍 1

In future, can you please reply in threads instead of spamming the main channel with a whole bunch of conversation @thheller @christian767

👍 2