I am working on a clojure project where I want to create a class in Java and then instantiate that class and call a method from within my clojure code.
My Java code is located in resources/MyClass.java
public class MyClass {
public static long myMethod() {
long i = 1;
return i;
}
}
And in my clojure code I have
(import MyClass)
...
(def my-object (MyClass.))
(.myMethod my-object)
I compiled my class and ran lein compile, but when I run my code I get
Exception in thread "main" java.lang.IllegalArgumentException: No matching field found: myMethod for class MyClass
at clojure.lang.Reflector.getInstanceField(Reflector.java:271)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:300)
What am I doing wrong? It looks like the import statement worked, as the the instantiation, but Im not able to call the method. Help is appreciated!
Thanks