最简单的方法是使用Maven,这里就是你需要做的:
获取的安装Maven 2副本。
得到Clojure Maven Plugin的副本,请访问其文件夹,运行安装MVN
通过运行以下命令安装clojure.jar到您的Maven仓库:
mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure -Dversion=1.1.0-alpha-SNAPSHOT -Dpackaging=jar
-Dfile=clojure.jar
现在,你需要创建一个pom.xml它会告诉行家如何建立你的项目
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.clojure</groupId>
<artifactId>hello-world</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.1-SNAPSHOT</version>
<configuration>
<sourceDirectories>
<sourceDirectory>src</sourceDirectory>
</sourceDirectories>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.1.0-alpha-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
所以,现在,说你有一个hello.clj看起来像:
(ns clojure.examples.hello
(:gen-class))
(defn -main[args]
(doto (javax.swing.JFrame. "Hello World")
(.add (javax.swing.JLabel. "Clojure Distributable"))
(.pack)
(.show)))
你的项目结构应该是这样的:
项目/ pom.xml的
项目/ src目录/ Clojure的/例子/你好。CLJ
如果你去到项目文件夹,然后运行mvn安装,它应该创建项目/目标/你好世界-1.0.jar这将有一个主要方法,你应该能够与
运行java -cp hello-world-1.0.jar:clojure.jar clojure.examples.hello
您可能还想看看One-Jar项目,它可以让您将应用程序和clojure库绑定到同一个jar中。
应该添加一些关于实际创建jar的细节。这里有一篇文章,使用Leiningen:http://zef.me/2470/building-clojure-projects-with-leiningen – semperos 2011-01-15 12:11:52