开发者

How to build a jar file from clojure source code on Windows XP

开发者 https://www.devze.com 2023-04-10 14:47 出处:网络
Could you please tell how to build a jar file from clojure s开发者_StackOverflow中文版ource code on window xp,

Could you please tell how to build a jar file from clojure s开发者_StackOverflow中文版ource code on window xp, Wihout using maven or such software? Only clojure and Windows XP


Without any tool, you're bound to do some quirky steps manually. Say you have clojure.jar in the current directory, along with a target folder for compilation named classes and a clojure source file in src/awesome.clj with the following code:

(ns awesome)

(defn life-universe-and-everything []
  (println "42"))

In order to compile it you will issue the following commands on the command line:

EDIT: use semicolon instead of colon to separate classpath elements in Windows environments

java -cp clojure.jar;classes;src clojure.main
Clojure 1.3.0
user=> (compile 'awesome)

This will produce the compiled classes into the classes folder. Please note that if your code depends on any library, you need to adapt the -cp parameter values when starting the JVM.

Than, you will create the JAR file using:

jar cvf awesome.jar -C classes .

Finally, to call your function:

java -cp clojure.jar;awesome.jar clojure.main -e "(use 'awesome) (life-universe-and-everything)"

I'd also advise you to read the official documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号