Could not locate Clojure resource on classpath

天大地大妈咪最大 提交于 2019-12-11 11:39:20

问题


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.

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.

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.

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.


回答1:


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();


来源:https://stackoverflow.com/questions/15116334/could-not-locate-clojure-resource-on-classpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!