Reputation: 2989
I'm trying to build my first clojure leiningen project but I have an issue using a specific java class in my code.
While coding, I was looking for a specific functionnality and found out about DatatypeConverter (http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html). Then I had to figure how to import the library. I don't know anything about Maven but I ended up somewhat (educated?) guessing I should looking for the library there https://search.maven.org/.
So there is what I ended up writing for my project.clj file:
(defproject game-backend "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"}
:main game-backend.core
:dependencies [
[org.clojure/clojure "1.8.0"]
[javax.xml.bind/jaxb-api "2.2.12"]
])
and here is my ns macro call in my core.clj file:
(ns game-backend.core
(:require [clojure.java.io])
(:import
(java.security DigestInputStream)
(java.io FileInputStream)
(javax.xml.bind DataTypeConverter)
)
)
and when I tun lein run
I get the following error (a package was downloaded at some point in time): Exception in thread "main" java.lang.ClassNotFoundException: javax.xml.bind.DataTypeConverter, compiling:(game_backend/core.clj:1:1)
I(m have no idea how many steps I've done wrong (all of them?). Can you please enlight me on how it should be done?
Upvotes: 3
Views: 5311
Reputation: 5231
Also you can add multiple classes of a package:
(:import (java.io File Bits BufferedInputStream))
Upvotes: 1
Reputation: 6509
Take a look inside your maven repository (.m2 directory). You will be able to find the jar file there. Then look at the .class files in that jar.
DatatypeConverter.class
That's one way to find that you should be using a lowercase 't'.
Upvotes: 3
Reputation: 1688
Try a lowercase 't' DatatypeConverter
(ns game-backend.core
(:require [clojure.java.io])
(:import
(java.security DigestInputStream)
(java.io FileInputStream)
(javax.xml.bind DatatypeConverter)
)
)
Upvotes: 7