如何添加目录到Clojure的类路径? [英] How to add directory to Clojure's classpath?
问题描述
我已经安装了带有Maven的库到〜/ .m2 / repository /目录。我想添加该路径到默认Clojure类路径。
任何提示?
干杯!
clj
Clojure 1.4.0
user => (require'[clojure.java.jmx:as jmx])
FileNotFoundException无法在类路径上找到clojure / java / jmx__init.class或clojure / java / jmx.clj:clojure.lang.RT.load(RT。 java:432)
类路径默认为:
user => (#/ URL / file / user / myuser / cljmx />#< URL file:/ usr / local / Cellar / clojure / 1.4.0 / clojure-1.4.0.jar>#< URL file:/user/myuser/cljmx/>)
pre>
nil
解决方案不痛苦,流行的方法是不要直接使用maven和classpaths以及JRE和使用leiningen: a href =https://github.com/technomancy/leiningen/> https://github.com/technomancy/leiningen/
否则,你可以修改
clj
中的任何内容,并以java喜欢的方式添加/设置类路径。请参见例如在Java类路径中设置多个jarsI have installed the libraries with Maven to the ~/.m2/repository/ directory. I would like to add that path to the default Clojure classpath. I could not find the documentation how to do that.
Any hints?
Cheers!
clj Clojure 1.4.0 user=> (require '[clojure.java.jmx :as jmx]) FileNotFoundException Could not locate clojure/java/jmx__init.class or clojure/java/jmx.clj on classpath: clojure.lang.RT.load (RT.java:432)
The class path by default is:
user=> (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))) (#<URL file:/Users/myuser/cljmx/> #<URL file:/usr/local/Cellar/clojure/1.4.0/clojure-1.4.0.jar> #<URL file:/Users/myuser/cljmx/>) nil
解决方案The non-painful, popular method is to not mess with maven and classpaths and the JRE directly and use leiningen: https://github.com/technomancy/leiningen/
Otherwise, you can modify whatever is in
clj
and add/set the classpath in whatever ways java likes. See for example Setting multiple jars in java classpath这篇关于如何添加目录到Clojure的类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!