如果使用`java`启动脚本,则看不到打印的值 [英] Can't see printed values if launch script with `java`
本文介绍了如果使用`java`启动脚本,则看不到打印的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码:
(ns test
(:gen-class))
(defn -main
[& args]
(println "hello!"))
但是当我运行 java -cp clojure-1.6.0 / clojure-1.6.0.jar clojure.main test.clj
时,我没有输出。为什么?如何解决此问题?
But when I run java -cp clojure-1.6.0/clojure-1.6.0.jar clojure.main test.clj
I get no output. Why? How to fix this?
推荐答案
ns
和 defn
不输出任何内容。如果您想通过调用 -main
函数来打印 hello!
,则必须添加一个函数调用在 test.clj
文件的末尾。
Both ns
and defn
do not output anything. If you would like to print "hello!"
by invoking the -main
function, you have to add a function call at the end of the test.clj
file.
(ns test
(:gen-class))
(defn -main
[& args]
(println "hello!"))
(-main)
这篇关于如果使用`java`启动脚本,则看不到打印的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文