简体   繁体   中英

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

Could you please tell how to build a jar file from clojure source 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM