Zuriar
Zuriar

Reputation: 11734

Calling a method on a Java class from Clojure

I have this simple Java source:

class HelloJava {

   public static String greetMe() {
      return "Hello, this is Java calling!";
   }

}

which I compile down into a class file called HelloJava.class

HelloWorld.class is in the same directory that I launch the Repl from.

How can I now call HelloJava.greetMe() in the Clojure REPL?

Upvotes: 0

Views: 320

Answers (1)

noisesmith
noisesmith

Reputation: 20194

Static methods are accessed via Class/method, and like most things in Clojure, are invoked via wrapping in parens:

(import org.user3231690.HelloJava)
(HelloJava/greetMe)

Upvotes: 1

Related Questions