3

I have a function in Java that I would like to call from Clojure. The particular prototype is the following:

public MyClass create(String aaa, File bbb, String[] args)

I therefore need to pass a String[] as a parameter, from a Clojure function. Passing any of the following:

  • (def args [])
  • (def args [""])
  • (def args ^String [])

all yield an exception: No matching method found: createScript for class BlaBla..

I have also seen this Java interop documentation, but I am probably missing something. How do I call this method from Clojure?

1 Answer 1

4
(.create (MyClass.) "aaa" (File. "my file") (into-array ["foo" "bar" "baz"]))

Should do the trick.

See https://clojuredocs.org/clojure.core/into-array for more details.

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.