yazz.com
yazz.com

Reputation: 58766

Calling Clojure from Java

Whenever I try to call clojure from java I get a class not found exception. I can call the Clojure from another Clojure class. What am I doing wrong?

Update:

I finally figured it out. I should have used forward slashes instead of "." in RT.load:

RT.load("namespace/file_name", true);

Upvotes: 3

Views: 960

Answers (1)

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91534

A lot of old outdated tutorials talk about using RT.load to run clojure code from java. this is left over from the stone age and no longer necessasary.

see this SO question

here is a teaser from that question showing the generally accepted java side:

/* Thanks clartaq for this example */

import com.domain.tiny;
public class Main {
    public static void main(String[] args) {
        System.out.println("(binomial 5 3): " + tiny.binomial(5, 3));
        System.out.println("(binomial 10042, 111): " + tiny.binomial(10042, 111));
    }
}

it should just look like normal java code. You're java code does not need to look any different just because the class it's calling happens to have been written in Clojure.

Upvotes: 5

Related Questions