如何在Windows XP上从clojure源代码构建jar文件 [英] How to build a jar file from clojure source code on Windows XP

查看:155
本文介绍了如何在Windows XP上从clojure源代码构建jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能告诉如何从clojure源代码在窗口xp,
上创建一个jar文件使用maven或这样的软件?只有clojure和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

推荐答案

没有任何工具,你必须手动做一些古怪的步骤。假设您在当前目录中有 clojure.jar ,以及名为 classes 的编译目标文件夹和clojure源使用以下代码在 src / awesome.clj 中创建文件:

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:

编辑:使用分号而不是冒号在Windows环境中分离类路径元素

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)

这将产生编译的类到 classes 文件夹。请注意,如果您的代码依赖于任何库,您需要在启动JVM时修改 -cp 参数值。

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.

比使用以下方法创建JAR文件:

Than, you will create the JAR file using:

jar cvf awesome.jar -C classes .

最后,调用您的函数:

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

我也建议您阅读官方文件

这篇关于如何在Windows XP上从clojure源代码构建jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆