Wednesday, 15 April 2015

java - Unable to call an instance method from Clojure. -



java - Unable to call an instance method from Clojure. -

i'm new java , clojure. previous experience in mutual lisp, thought give clojure try. i'm unable figure out few basic things.

this actual java code.

import syntaxtree.*; import visitor.*; public class main { public static void main(string [] args) { seek { node root = new microjavaparser(system.in).goal(); system.out.println("program parsed successfully"); } grab (parseexception e) { system.out.println(e.tostring()); } } }

when run code, outcome expected.

└──╼ java main < ../input/factorial.java programme parsed

in clojure tried :

(ns clj-assign2.core) (defn -main [] (def root (.goal (microjavaparser. (. scheme in)))) (println "successfully parsed"))

but when code run, next exception raised :

└──╼ lein run < ../assign2/input/factorial.java exception in thread "main" java.lang.illegalargumentexception: no matching field found: goal class microjavaparser @ clojure.lang.reflector.getinstancefield(reflector.java:271) @ clojure.lang.reflector.invokenoarginstancemember(reflector.java:300) @ clj_assign2.core$_main.invoke(core.clj:7) < --- snipped --- >

what doing wrong here?

maybe missing import statement in clojure program?

java clojure leiningen clojure-java-interop

No comments:

Post a Comment