Hi thelmuth

Here's a fully worked example. It calls the Clojure function
myco.dashed-namespace.app.core/start!. Save it to
src/myco/dashed_namespace/app/Main.java.

package myco.dashed_namespace.app;

import clojure.java.api.Clojure;
import clojure.lang.IFn;

public class Main {
    public static void main(String[] args) {
        try {
            IFn require = Clojure.var("clojure.core", "require");
            require.invoke(Clojure.read("myco.dashed-namespace.app.core"));

            Clojure.var("myco.dashed-namespace.app.core", "start!").invoke();
        }
        catch (Throwable e) {
            System.out.println(e.getMessage());
        }
    }
}


On Fri, Jun 2, 2017 at 1:24 PM James Reeves <ja...@booleanknot.com> wrote:

> There's a brief section on this on the Clojure website:
>
> https://clojure.org/reference/java_interop#_calling_clojure_from_java
>
> On 2 June 2017 at 01:35, thelmuth <trh...@gmail.com> wrote:
>
>> What is the best way to call a Clojure function from Java?
>>
>> Most of the resources I have found are either very old or don't go into
>> enough detail. I am a Clojure programmer with very little Java background,
>> and have been having trouble with the methods I've found, especially
>> classpath issues.
>>
>> --
>> 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
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> James Reeves
> booleanknot.com
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to