无法在类路径上找到Clojure资源 [英] Could not locate Clojure resource on classpath

查看:292
本文介绍了无法在类路径上找到Clojure资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访问我的一些clojure函数在我的Java代码(我使用Eclipse和CounterClockWise)。首先,我不知道该怎么办?但后来我在此处找到了一些答案。

I am trying to access some of my clojure functions in my Java code (I am using Eclipse and CounterClockWise). Firstly, I was not sure how to do it? But then I found some answer here.

我使用 clojure.lang.RT包调用 .clj 文件在我的Java代码。命名命名空间, .clj 文件正确的约定遵循如 ns test.clojure.core test.clojure package where-in core is .clj 文件。还有一些信息,我添加了java源码路径(即java源码路径 src / test / java )和源路径(即源路径 src / test / clojure )在我的 project.clj

I am using clojure.lang.RT package for calling .clj files in my Java code. While naming namespaces, .clj files proper conventions has been followed like ns test.clojure.core is in test.clojure package where-in core is .clj file. Also upon following some information, I have added java-source-path (i.e. java-source-path src/test/java) and source-path (i.e. source-path src/test/clojure) in my project.clj.

但是,当我运行我的Java文件时出现错误 - a)无法在classpath上找到Clojure资源 b)尝试呼叫未绑定的fn

But, when I run my Java file following error is given - a) Could not locate Clojure resource on classpath b) Attempting to call unbound fn.

如果社区中的任何人都可以帮助我)通过详细的过程或教程我会感激,因为只有信息我可以得到(使用 clojure.lang.RT )是很少。

Please if anyone in community could help me (assuming I am absolute beginner) through detailed procedure or tutorial I would be grateful, as only information I could get (for using clojure.lang.RT) is very little.

期待获得完整答案以结束我的失望。

Looking forward to get a complete answer to end my frustration.

推荐答案

p>我想你使用 RT.loadResourceScript 这是造成的问题。
你可以尝试这样的:

I guess you are using RT.loadResourceScript which is causing the proble. You can try out something like this:

//Load the namespace 
    RT.var("clojure.core","eval").invoke(RT.var("clojure.core","read-string").invoke("(use 'test.clojure.core)"));

//Find a function in namespace
    IFn fn = (IFn)RT.var("test.clojure.core","hello");

//Call that function
    fn.invoke();

这篇关于无法在类路径上找到Clojure资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆