1

I am very close to being able to do this. I chose JDatePicker to see what it takes. Steps:

1) git clone https://github.com/JDatePicker/JDatePicker
2) cd JDatePicker
3) mvn package

Then installed localrepo Don't know if there is an easier way but this seems to be the way pointed to by others on the internet.

4) vi  ~/.lein/profiles.clj
5) {:user {:plugins [[lein-localrepo "0.5.3"]]}}

Inside JDatePicker directory where the .jar file is located, used localrepo to give jdatepicker a coordinate so that lein projects can use it. I am using lein version:

idf@idf-Satellite-C55t-A ~/Documents/clojure/jdatepickertest $ lein version
Leiningen 2.5.0 on Java 1.7.0_72 Java HotSpot(TM) 64-Bit Server VM
idf@idf-Satellite-C55t-A ~/Documents/clojure/jdatepickertest $ 

6) lein localrepo install jdatepicker-2.0.0-SNAPSHOT.jar org/jdatepicker 2.0.0

Created a new clojure project to see if I can access it

7) lein new jdatepickertest
8) cd jdatepickertest

modified the project.clj file and added [org/jdatepicker "2.0.0"] to the dependencies section

9)    
 (defproject jdatepickertest "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/jdatepicker     "2.0.0"]
         ] )

did a lein deps which returned nothing so assumed all went well

10) lein deps

launched a repl inside jdatepickertest directory

11) lein repl

Now I try to use jdatepicker from clojure but I can't seem to access it?

12) 
nREPL server started on port 43286 on host 127.0.0.1 - nrepl://127.0.0.1:43286
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.7.0_72-b14
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e
user=> (clojure-version)
"1.6.0"
user=> (require '[jdatepicker :as datepicker])
FileNotFoundException Could not locate jdatepicker__init.class or jdatepicker.clj on classpath:   clojure.lang.RT.load (RT.java:443)
user=> (require '[org.jdatepicker :as datepicker])

FileNotFoundException Could not locate org/jdatepicker__init.class or org/jdatepicker.clj on classpath:   clojure.lang.RT.load (RT.java:443)
user=> 
Ivan
  • 7,448
  • 14
  • 69
  • 134

1 Answers1

5

You don't need lein-localrepo for this, it would suffice to specify the maven coordinates in your project.clj

[org.jdatepicker/jdatepicker "1.3.4"]

require is for clojure namespaces. Java classes will be looked up in the classpath when used, and you can use import if you prefer to use the unqualified class name.

(import org.jdatepicker.JDatePicker)

After that you can proceed to use JDatePicker via interop as you would any other java library.

noisesmith
  • 20,076
  • 2
  • 41
  • 49
  • Quick question,how do I instantiate a JDatePicker inside a panel and display it? – Ivan Dec 04 '14 at 21:08
  • The guide at [clojure.org](http://clojure.org/java_interop) is pretty good. Look up what constructor you want to use, and invoke it from Clojure. `(JDatePicker. )` – noisesmith Dec 04 '14 at 21:11
  • Please see this question http://stackoverflow.com/questions/27304476/simple-java-interop-from-clojure – Ivan Dec 04 '14 at 21:30
  • For starters, you didn't import the class you are actually using. Check out the docs for java interop, it isn't super complex. – noisesmith Dec 04 '14 at 21:33
  • See changes. Everything is obvious once you know how to do it. This is a bit confusing. – Ivan Dec 04 '14 at 21:42
  • I didn't say anything was obvious. Your mistakes show an unfamiliarity with basic concepts in Clojure java interop, and that is the best intro I know of to the topic. – noisesmith Dec 04 '14 at 22:23