2

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.

jrahme
  • 253
  • 1
  • 12
  • 1
    well, jars are obviously not sources. Check this out http://stackoverflow.com/questions/2404426/leiningen-how-to-add-dependencies-for-local-jars – leetwinski Oct 19 '15 at 15:23

1 Answers1

1

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.

Ricardo Acuna
  • 530
  • 2
  • 10