2
我在学clojure与leiningen。我写了一个简单的代码来测试雷音 & Java的罐子命令。这里是我的project.clj文件:为什么使用java -jar调用print函数时不打印?
$ cat project.clj
(defproject hello "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]]
:main ^:skip-aot hello.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
这里是我的源代码:
$ cat src/hello/core.clj
(ns hello.core
(:gen-class))
(defn -main
[& args]
(print "Hello, World!"))
当我运行此代码雷音,它做工精细。它在这里
$ lein run
Hello, World!$
所示。当我试图运行Java的罐子,它没有工作
$ lein uberjar
Compiling hello.core
Created /home/rishi/hello/target/uberjar/hello-0.1.0-SNAPSHOT.jar
Created /home/rishi/hello/target/uberjar/hello-0.1.0-SNAPSHOT-standalone.jar
$ java -jar target/uberjar/hello-0.1.0-SNAPSHOT-standalone.jar
我不明白,为什么我没有得到所需的输出与的java -jar?
如果我更换打印与的println在源文件中,我得到了所需的输出与两个雷音运行 & Java的罐子。
酷!我明白了。我得到了我的答案。谢谢。 @noisesmith –