Clojure访问Java接口常量
我正在尝试从Clojure中访问常量:Clojure访问Java接口常量,clojure,interface,jcs,Clojure,Interface,Jcs,我正在尝试从Clojure中访问常量: public interface CacheConstants { /** This is the name of the config file that we will look for by default. */ String DEFAULT_CONFIG = "/cache.ccf"; /** Delimiter of a cache name component. This is used for hierarchic
public interface CacheConstants
{
/** This is the name of the config file that we will look for by default. */
String DEFAULT_CONFIG = "/cache.ccf";
/** Delimiter of a cache name component. This is used for hierarchical deletion */
String NAME_COMPONENT_DELIMITER = ":";
}
Clojure尝试:
(import '[org.apache.jcs.engine.CacheConstants])
org.apache.jcs.engine.CacheConstants/DEFAULT_CONFIG
;; clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: org.apache.jcs.engine.CacheConstants
如何访问这两个值?以下内容适用于本地java接口:
文件:srcjava/jroot/Const.java
package jroot;
public interface Const {
long ANSWER = 42;
文件:project.clj
(defproject clj "0.1.0-SNAPSHOT"
<snip>
:java-source-paths ["src-java"]
)
注意:import
向量中的空格(非常重要)
此外,如果使用此语法:
(defproject test-project "0.1.0-SNAPSHOT"
:description "Blah blah blah"
...
:resource-paths ["resources/Siebel.jar" "resources/SiebelJI_enu.jar"])
您可以访问jar文件中的任何内容吗?也许这就是问题所在。@AlanThompson我可以使用jar提供的缓存机制,否则,是的。谢谢,这似乎确实指向了一个丢失的jar。也许是一个错误的版本。我会检查并接受你的回答。
(defproject test-project "0.1.0-SNAPSHOT"
:description "Blah blah blah"
...
:resource-paths ["resources/Siebel.jar" "resources/SiebelJI_enu.jar"])