On Feb 18, 7:49 pm, mikel <mev...@mac.com> wrote:
> (I assume there must be something simple I'm not noticing about how to
> set up my classpath properly).

An attempt to make things clear...

There are two directories involved in gen-class compilation:
1. your sources dir
2. your compiled files dir, which is set in the Java system property
"clojure.compile.path".

The compiled dir must exist; Clojure will not create it.

BOTH dirs must be on the classpath, like this:

    java \
    -cp clojure.jar:/your/classes/dir:/your/sources/dir \
    -Dclojure.compile.path=/your/classes/dir \
    clojure.main

Since your namespace is "xg.gf", there should be a file named
/your/sources/dir/xg/gf.clj

However, the "standard" way to use gen-class is to have a namespace
with the same name as the resulting Java class, like this:

In the file "/your/sources/dir/xg/gf/GenericFunction.clj":
    (ns xg.gf.GenericFunction
      (:gen-class :extends clojure.lang.AFn))

Now (compile 'xg.gf.GenericFunction) will generate a Java class named
"xg.gf.GenericFunction".  When THAT class is loaded later on, it will
use the functions defined in the Clojure namespace
"xg.gf.GenericFunction".

It's important to remember that gen-class really only generates a stub
class, which dynamically loads a Clojure namespace (from source or
compiled) and uses the definitions from that namespace.

-Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
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
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