1

I try to import two org.apache.lucene jars in lein project and get a ClassNotFoundException.

Here is my project.clj file:

(defproject clj_processing_tweets "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.apache.lucene/lucene-core "4.10.3"]
                 [org.apache.lucene/lucene-analyzers-common "4.10.3"]]
  :profiles {:dev {:dependencies [[speclj "3.1.0"]]}}
  :plugins [[speclj "3.1.0"]]
  :test-paths ["spec"])

After running lein deps I send core.clj to the lein repl and I got

CompilerException java.lang.ClassNotFoundException: org.apache.lucene.analysis.*, compiling:(clj_processing_tweets/core.
clj:1:36)

Here is my core.clj file:

(ns clj_processing_tweets.core
  (:import [org.apache.lucene.analysis *]))

Thanks for help.

user3639782
  • 487
  • 3
  • 10

1 Answers1

3

You will need to import each class you want to use separately, as clojure doesn't allow you to specify a wildcard on Java import.

See this answer to a more general question: https://stackoverflow.com/a/1213628/66722

So, for example:

(ns clj_processing_tweets.core
  (:import [org.apache.lucene.analysis Analyzer Tokenizer]))
Community
  • 1
  • 1
Martin Dow
  • 5,273
  • 4
  • 30
  • 43