Clojurescript:错误:无法找到或加载主类clojure.main

时间:2015-02-12 15:25:25

标签: clojurescript

我按照quick start guide安装了Clojurescript。

我把git repo拉到了~/clojurescriptCLOJURESCRIPT_HOME设置为~/clojurescriptclojurescript/bin已添加到系统路径。

当我尝试使用命令cljsc时,我收到以下错误

Could not find or load main class clojure.main

我该如何解决?

4 个答案:

答案 0 :(得分:1)

我今天正在阅读本教程。

我在这里检查了这个错误。独立jar的版本是正确的。问题是由core.cljs文件中的“输入错误”引起的。字符串“Hello world!”不在双引号。最初字符串是单引号,包含逗号。

我遇到的另一个问题是让java命令工作。我使用的是Cygwin64终端。

Cygwin64终端的正确命令是:

$ java -cp "cljs.jar;src" clojure.main build.clj

答案 1 :(得分:1)

在我的情况下,我错误地输入了Windows命令,命令中有" +确保你的根文件夹中有cljs.jar bes

java -cp cljs.jar:src clojure.main build.clj

我希望有一天能帮助别人。:)

答案 2 :(得分:0)

好5年后回来。

当从没有文件clj --main cljs.main --compile hello-world.core --repldeps.end的目录或路径运行cljs.jar时,就会出现此错误。

考虑位于https://clojurescript.org/guides/quick-start的目录结构,

hello-world  #### Run that command in this directory
├─ src   
│  └─ hello_world
│     └─ core.cljs 
├─ cljs.jar 
└─ deps.edn 

$ cd hello-world
$ clj --main cljs.main --compile hello-world.core --repl

答案 3 :(得分:0)

如果您使用leiningen创建了项目,那么您的项目cli看起来会像这样


(defproject clojuredemo "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.6.0"]]
  )

在:dependencies之后添加以下行

 :jar-name "<project-name>.jar"
 :jar-path "/target/<project-name>.jar"

注意:您需要用项目替换项目名称

之后,运行以下命令


lein jar

相关问题