jrahme
jrahme

Reputation: 273

Adding Classes to Clojure

In my clojure project I have a dependency on the javax.jms.MessageListener library. I have this class file in my project in the following directory

My-project
|java-
|    |src -
|    |    |myJavaFile.java
|    |    |jars -
|    |       |library1.jar
|    |       |library2.jar
|    |       |libarary3.jar
|    |javax -
|    |      |jms -
|    |          |MessageListener.class
|project.clj
|src -
|    |my-program1.clj
|    |my-program2.clj
|    |my-program3.clj

Then in my project.clj file I have my java-source-paths set to

:java-source-paths ["java/src" "java/src/jars/" "java/javax/jms"]

but when I go to run my project via lein repl, I get compilation errors saying

java.lang.NoClassDefFoundError: javax/jms/MessageListener

Caused by: java.lang.ClassNotFoundException: javax.jms.MessageListener

From what I've read the messagelistener.class and my library jars should be included in my classpath when the project is running but that doesn't seem to be the case.

Upvotes: 2

Views: 122

Answers (1)

RJ Acuña
RJ Acuña

Reputation: 530

It is my understanding that the directory structure of java projects has to match the name of the namespaces. For instance package_name.classname has to be in the folder package_name on the classpath https://docs.oracle.com/javase/tutorial/java/package/managingfiles.html

But of course using either Leiningen or Boot you just need to add [javax.jms/jms-api "1.1-rev-1"] to the :dependencies.

Upvotes: 1

Related Questions