On Sat, Oct 24, 2009 at 10:50 PM, Richard Newman <holyg...@gmail.com> wrote: > >> for anyone who has this same problem. The only solution that I've >> gotten so far that works is to use a java file that launches my >> clojure files. I'm still looking for a better way to do this. > > I've had success on several projects with: > > (ns com.foo.bar > (:refer-clojure) > (:gen-class)) ; I haven't even tried adding :main true. > > (defn -main [& args] > ...) > > > with the appropriate Ant chunk to build the manifest: > > <!-- Build the classpath to point to any dependencies. --> > <manifestclasspath property="lib.list" jarfile="${base.jarfile}"> > <classpath refid="manifest.path"/> > </manifestclasspath> > > <!-- Make the output jar with Main-Class. --> > <target name="solitary_jar" description="Create jar with pointers > to dependencies." depends="compile_clojure"> > <jar index="false" jarfile="${solitary.jarfile}"> > <fileset dir="${base.build}" includes="**/*.class,**/ > *.properties"/> > <manifest> > <attribute name="Main-Class" value="com.foo.bar"/> > <attribute name="Class-Path" value="${lib.list}"/> > </manifest> > </jar> > </target> > > > This allows you to do > > java -jar my-jar > > which, on my Mac at least, means it'll run when you double-click it. > > The difference here is that I'm AOT-compiling everything, but you're > not. Is that correct? > > If you're trying to bundle your .clj files into the JAR, you might > have trouble — you'll need somehow to get Clojure's classloader to > look for your main class, because the Java classloader won't look > for .clj files, and wouldn't know what to do with them anyway. gen- > class only works if you AOT-compile. > > I can't see any reason why you wouldn't AOT-compile when you're > building a jar. > > >
I have a clojure project stub at, http://github.com/nakkaya/clojure-stub That will let you build a executable jar. running ant deps will download the clojure.jar and clojure-contrib.jar running ant setup will create the required sources to create a hello world application. running ant compile will create single executable jar that you can distribute. You can use it as a starting point for your application. -- Nurullah Akkaya http://nakkaya.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 -~----------~----~----~----~------~----~------~--~---