Hi,

Am 22.12.2010 um 10:13 schrieb Mark Engelberg:

> I'm trying to figure out how to bundle up some Clojure code into a jar
> to be accessed by someone in Java.
> 
> My google search turned up this link:
> http://java.dzone.com/articles/java-clojure-interop-calling
> which dates back to Clojure 1.1.
> 
> Seems like a lot of changes have occurred since then -- static
> functions, protocols, etc.  So has the "calling Clojure from Java"
> story changed with Clojure 1.3?  If so, can anyone provide pointers to
> some recent examples?

If you just want to invoke some functions, you don't have to define a class. 
You can retrieve the corresponding Vars.

Var someFn = RT.var("you.name.space", "some-fn");
…
someFn.invoke("Some", "arguments", goHere, 123);

It is a little ugly, but works with any function, in particular static and 
protocol functions. If you want a less rough interface, you can still go the 
gen-class route from the article. But this will come at the cost of one level 
of indirection on method calls.

Sincerely
Meikel

PS: Here an example of the above approach incl. namespace loading: 
https://bitbucket.org/kotarak/vimclojure/src/4f2b588aebbe/server/src/main/java/vimclojure/Nail.java

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to