This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-04
Channels
- # announcements (1)
- # architecture (7)
- # beginners (44)
- # biff (11)
- # calva (15)
- # cider (5)
- # clerk (9)
- # clj-kondo (20)
- # clj-on-windows (19)
- # clj-yaml (2)
- # cljs-dev (39)
- # clojure (52)
- # clojure-czech (2)
- # clojure-dev (11)
- # clojure-europe (28)
- # clojure-hamburg (10)
- # clojure-hungary (3)
- # clojure-nl (1)
- # clojure-norway (59)
- # clojure-uk (5)
- # clojured (2)
- # clojurescript (33)
- # conjure (2)
- # datahike (1)
- # datomic (5)
- # defnpodcast (5)
- # emacs (18)
- # figwheel (2)
- # funcool (6)
- # graphql (1)
- # hyperfiddle (11)
- # jobs (3)
- # joyride (13)
- # malli (6)
- # music (4)
- # off-topic (45)
- # polylith (11)
- # practicalli (3)
- # rdf (3)
- # releases (1)
- # scittle (8)
- # shadow-cljs (13)
- # specter (2)
- # squint (8)
- # testing (6)
- # tools-deps (21)
- # xtdb (2)
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
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.
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
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.
(updated that Wikibooks page to link to that and remove the old clojure.lang.RT
stuff)
@U0FH1UL84 ☝️:skin-tone-2:
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))
Are you sure your classpath for running your Java code actually includes your code?
(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)
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)
You're not requiring your namespace.
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.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 🙂