I am trying to call a clojure function from a java class but even though the clojure file is located at the same place as the java class, its throwing
Exception in thread "main" java.io.FileNotFoundException: Could not locate com/foo/names__init.class or com/foo/names.clj on classpath.
This is my project structure:
src
main
java
com
foo
names.clj
TestClj.java
names.clj
(ns com.foo.names)
(defn add-me
[one two]
(+ one two))
TestClj.java
public class TestClj {
private static final IFn REQUIRE = Clojure.var("clojure.core", "require");
public TestClj(String ns) {
this.ns = ns;
REQUIRE.invoke(Clojure.read(ns)); <- Breaks here
}
public static void main(String[] args) {
TestClj clj = new TestClj("com.foo.names");
Clojure.var("com.foo.names", "add-me").invoke(1, 2);
}
}
What am I missing here?
EDIT Adding the pom file
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.7.0-alpha5</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>clojars.org</id>
<name>Clojars repository</name>
<url>https://clojars.org/repo</url>
</repository>
</repositories>