clojure/lein REPL 与 jline
由于某种原因,我无法让 clojure REPL 与 jline 一起使用,我所做的是 git 从 github 上克隆 clojure 存储库,然后运行 ant 来构建它,然后我将 jline-0.9.94.jar 下载到包含 clojure.jar 的目录中,然后运行以下命令:
java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
并得到以下错误:
Exception in thread "main" java.lang.ClassNotFoundException: clojure.main
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at jline.ConsoleRunner.main(Unknown Source)
这是我当前目录中的文件:
vvshs-macbook-2:clojure vvsh$ ls
build.xml clojure-sources-1.2.0-master-SNAPSHOT.jar epl-v10.html src
classes clojure-sources.jar jline-0.9.94.jar test
clojure-1.2.0-master-SNAPSHOT.jar clojure.iml pom-template.xml
clojure-slim-1.2.0-master-SNAPSHOT.jar clojure.jar pom.xml
clojure-slim.jar doc readme.txt
vvshs-macbook-2:clojure vvsh$
我在 clojure 1.1 和 lein repl 上遇到了相同的错误(似乎 lein 维护自己的 clojure 版本)。
顺便说一句,这是在 mac ox 10.5.8 上
java version "1.5.0_24"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_24-b02-357-9M3165)
Java HotSpot(TM) Client VM (build 1.5.0_24-149, mixed mode, sharing)
有人知道出了什么问题以及如何修复它吗?因为我真的想让 lein repl 开始一个项目。
For some reason I can't get clojure REPL working with jline, what i did was git clone the clojure repository off github then run ant to build it, then i download jline-0.9.94.jar to the directory with clojure.jar, then run the following command:
java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
And get the following errors:
Exception in thread "main" java.lang.ClassNotFoundException: clojure.main
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at jline.ConsoleRunner.main(Unknown Source)
Here are the files in my current directory:
vvshs-macbook-2:clojure vvsh$ ls
build.xml clojure-sources-1.2.0-master-SNAPSHOT.jar epl-v10.html src
classes clojure-sources.jar jline-0.9.94.jar test
clojure-1.2.0-master-SNAPSHOT.jar clojure.iml pom-template.xml
clojure-slim-1.2.0-master-SNAPSHOT.jar clojure.jar pom.xml
clojure-slim.jar doc readme.txt
vvshs-macbook-2:clojure vvsh$
I got the same error on clojure 1.1 and lein repl(it seems lein maintain its own version of clojure).
By the way, this is on mac ox 10.5.8
java version "1.5.0_24"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_24-b02-357-9M3165)
Java HotSpot(TM) Client VM (build 1.5.0_24-149, mixed mode, sharing)
Anybody know what's wrong and how to fix it? As I really want to get lein repl working to start a project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我今天解决了同样的问题,从
/Library/Java/Extensions
中删除了多余的jline*.jar
,只在CLASSPATH
中留下一个 jline 安装。更长的解释:我试图构建labrepl,它安装其所有依赖项在子目录
lib
中,但我之前已通过将 .jar 文件复制到/Library/Java/Extensions
来设置 jline。 显然,java.lang.ClassLoader
无法处理jline的两次安装,并且只要有两个地方可用,启动 Clojure REPL 的命令行将无法找到类jline.ConsoleRunner
和clojure.main
中的后一个,取决于它们被赋予java
命令的顺序。我希望这有帮助。
I solved the same problem today by removing a redundant
jline*.jar
from/Library/Java/Extensions
, leaving just one jline installation inCLASSPATH
.Longer explanation: I was trying to build labrepl, which installs all its dependencies in subdirectory
lib
, but I had previously set up jline by copying the .jar file to/Library/Java/Extensions
. Apparently,java.lang.ClassLoader
couldn't handle two installations of jline, and as long as there were ones available in two places, the command line starting a Clojure REPL would fail finding the latter one of classesjline.ConsoleRunner
andclojure.main
, depending on the order they were given to thejava
command.I hope this helps.
请参阅我的叉子上安装的替代说明:
http://github.com/jedschneider/leiningen
我发送了拉取请求来更新自述文件,但没有得到回复。安装 lein 后,您可以将 bin/leiningen.sh 放入 ~/bin 中并在任何地方调用它。我在 .bash_profile 上添加了一个快捷方式
alias lein="~/bin/leiningen.sh"
,然后调用
lein repl
启动 shell并签出 labrepl,它是很棒的学习工具。
http://github.com/relevance/labrepl
see my alternative instructions for install on my fork:
http://github.com/jedschneider/leiningen
I sent a pull request to update the readme, but didn't get a response on it. once you have lein installed, you can put the bin/leiningen.sh in your ~/bin and call it anywhere. i put a shortcut on my .bash_profile
alias lein="~/bin/leiningen.sh"
and then call
lein repl
to launch a shellalso checkout the labrepl which is a great learning tool.
http://github.com/relevance/labrepl
您的 java ... 命令看起来不错,我会仔细检查所有罐子是否都在您认为应该在的位置(并且它们是您认为的罐子) ,即
clojure.jar
实际上是您在本地构建的,而不是一些超级过时的)。如果您想使用 Leiningen 进行 lein repl,那也是可能的。请注意,说它“维护自己的 Clojure 版本”并不准确。 Leiningen 是一个构建工具,用作面向项目的工作流程的一部分,并且单独的 Clojure jar 是特定于项目的。要创建一个示例项目来进行操作,请在方便的地方说
lein new foo
。然后你需要cd foo
,获取你的 Clojure &使用lein deps
构建 contrib jar(lein new
提供的project.clj
框架已包含两者的条目)并使用启动 REPL lein repl
。最后,您可以使用新的
cljr
项目;它有一个全面的自述文件,应该可以让您立即开始使用,有了它,您就可以在任何地方使用cljr repl
来获取 Clojure REPL,而无需创建“项目”。Your
java ...
command looks fine, I'd double check if all the jars are where you think they should be (and that they are the jars you think they are, i.e.clojure.jar
is actually the one you built locally and not some super-outdated one).If you want to use Leiningen for
lein repl
, that's possible too. Note that it isn't accurate to say that it "maintains its own version of Clojure"; Leiningen is a build tool, used as part of a project-oriented workflow, and the separate Clojure jars are project-specific. To create a sample project to play around in, saylein new foo
someplace convenient. Then you'll need tocd foo
, get your Clojure & contrib jars withlein deps
(theproject.clj
skeleton provided bylein new
already contains entries for both) and start a REPL withlein repl
.Finally, you could use the new
cljr
project; it has a comprehensive README which should get you started in no time, and with it you'll be able to saycljr repl
to get a Clojure REPL anywhere, without the need to create a "project".我遇到了同样的问题。 jline.ConsoleRunner(至少关于我使用的 jline-0.9.5)似乎无法在从“java”命令的 -cp 选项添加到类搜索路径的路径中找到类文件。这意味着它在当前目录中找不到这两个类。我也通过复制 /Library/Java/Extensions/ 下的 clojure.main 解决了这个问题。
I met the same problem. jline.ConsoleRunner (at least about jline-0.9.5 which I use) seems not to be able to find class files in the path added to class search paths from -cp option of 'java' command. It means it can't find neither classes in your current directory. I solved this by copying clojure.main under /Library/Java/Extensions/ too.