tools-deps

2023-05-04T13:46:35.545419Z

I can't seem to use compile-clj with certain dependencies but the project can launch the clojure repl and use the dependency as normal. I wonder if it is something to do with the fact that I'm on windows and using the scoop clojure via bash.

clj -T:build jar
Error: Could not find or load main class Dumais\AppData\Local\Temp\compile-clj6495804517722369898\compile-clj;target.classes;src;resources;C:\Users\Paul
Caused by: java.lang.ClassNotFoundException: Dumais\AppData\Local\Temp\compile-clj6495804517722369898\compile-clj;target/classes;src;resources;C:\Users\Paul
Execution error (ExceptionInfo) at clojure.tools.build.tasks.compile-clj/compile-clj (compile_clj.clj:114).
Clojure compilation failed, working dir preserved: C:\Users\Paul Dumais\AppData\Local\Temp\compile-clj6495804517722369898

2023-05-04T13:47:55.967529Z

Notice how it's seems to be looking for main class that is broken by the fact that my user name has a space in it.

2023-05-04T13:48:48.110169Z

This only happens when I depend on certain java dependencies found in a maven repo.

2023-05-04T15:40:34.220289Z

It turns out I don't need this anyway! I wanted to call Clojure code from java but I can just do this: https://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java

2023-05-05T16:46:30.317379Z

Now, I want to make an uberjar but because of the original bug I mentioned, I will have to try leiningen to make an uberjar or perhaps use maven to and embed clojure files as I already demonstrated as working. Or use a linux vm... probably several options.

2023-05-05T16:48:52.058049Z

maybe there is a windows channel...

seancorfield 2023-05-05T19:12:15.546199Z

#clj-on-windows @pauld

👍 1
seancorfield 2023-05-04T17:28:45.101999Z

That is horribly outdated. (most of that wiki is objectively terrible). See https://clojure.org/reference/java_interop#_calling_clojure_from_java for the up-to-date way to call Clojure from Java.

seancorfield 2023-05-04T17:38:35.613349Z

(updated that Wikibooks page to link to that and remove the old clojure.lang.RT stuff)

👍 1
seancorfield 2023-05-04T17:38:49.997749Z

@pauld point_up::skin-tone-2

2023-05-04T19:16:57.287419Z

Does this method require a compiled clojure class?

2023-05-04T19:18:42.196819Z

Nevermind, I read the docs.

2023-05-04T19:55:41.744819Z

Hmm, I can't get this var to bind. I have a simple stub example in my maven project.

IFn test = Clojure.var("clojure.core", "+");
        Object testResult = test.invoke(1, 2);
The above works, but I can't figure out how to get this to work:
IFn foo = Clojure.var("com.company.test", "foo");
        Object result = foo.invoke("hi", "there");
I have test.clj file on the classpath at com/company/test.clj with this:
(ns com.company.test)

(defn foo [a b]
  (str a " " b))

seancorfield 2023-05-04T19:57:10.250269Z

Are you sure your classpath for running your Java code actually includes your code?

seancorfield 2023-05-04T19:58:07.390779Z

(and it would help if you provided details of exactly what "doesn't work" -- i.e., what errors you are getting on which lines of code)

2023-05-04T20:03:24.273899Z

java.lang.IllegalStateException: Attempting to call unbound fn: #'com/company/teast/foo
	at clojure.lang.Var$Unbound.throwArity(Var.java:45)
	at clojure.lang.AFn.invoke(AFn.java:36)
	at clojure.lang.Var.invoke(Var.java:388)

seancorfield 2023-05-04T20:03:55.320959Z

You're not requiring your namespace.

seancorfield 2023-05-04T20:04:57.445279Z

Per the docs I linked to: > Functions in clojure.core are automatically loaded. Other namespaces can be loaded via require:

IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read("clojure.set"));
That includes requiring your own code before calling it.

2023-05-04T20:05:47.043259Z

omg, reading skill are worse than I feared! Thanks. Trying out now.

2023-05-04T20:16:56.816639Z

That worked! Thanks a bunch.

👍🏻 1
seancorfield 2023-05-04T20:29:25.635239Z

We had a bunch of legacy ColdFusion apps and this was how we were able to slowly rewrite them into Clojure from the bottom up 🙂

👍 1