I don't know how my example fits your needs, but I use something like:

# /bin/sh
java -cp "lib/*":"src" clojure.main -e "(require 'my-project.core)
(my-project.core/print-hello)"

assuming, that in lib all neccesary libs are placed (clojure.jar,
clojure-contrib.jar, etc)
To download needed libs in lib directory I use "lein deps"
If you want to run examples then you can use
# /bin/sh
java -cp "lib/*":"examples" clojure.main -e "(require 'example-1)
(example-1/print-hello)"

Note that if you use namespaces with dashes (e.g. example-1), file should
have name example_1.clj (replace dashes with underscores)

You can also make java class with main method and compile and execute it.
How to do it described here:
http://clojure.org/compilation

Regards,
Nikita Beloglazov



On Mon, Aug 2, 2010 at 12:09 AM, jandot <[email protected]> wrote:

> Hi all,
>
> I'm writing a library which is organized using "lein new", so the
> directory structure contains an "src" and "test". I have added a
> directory "examples" with scripts that should be able to run by just
> typing "./example-1.clj".
>
> So the directory structure is:
> <pre>
>  +- project.clj
>  +- src
>  |    +- my-project
>  |            +- core.clj
>  |            +- io.clj
>  |            +- conversions.clj
>  +- test
>  +- examples
>       +- example-1.clj
>       +- example-2.clj
> </pre>
>
> Suppose that src/my-project/core.clj has the following contents:
>  (ns my-project.core)
>  (defn print-hello [] "Hello world")
>
> I can run that code from the repl (in my case: using liebke's "cljr
> repl") with:
>  (load-file "core.clj")
>  (print-hello)
>
> However, I have not been able yet to create the example script that
> should be executable by itself. What should that file look like? There
> are basically 2 issues: the she-bang line and the namespace. I've
> tried using different versions of "/usr/bin/env cljr run" and "/usr/
> bin/env java -cp cljr.jar ..." in the she-bang line, but no luck. Same
> goes for loading the my-project source files.
>
> It'll be obvious to you that I don't know java :-) Should be simple,
> but
>
> Many thanks,
> jan.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]<clojure%[email protected]>
> 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 post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to