wow I can't believe that worked, I mean look:
(ns helloworld.core
* (:import nl.bitwalker.useragentutils.UserAgent)*
(:gen-class :main true))
(defn -main
[& args]
* (println (UserAgent/parseUserAgentString "uas"))*
)
this works, but replace the import line with either this:
*(:import [nl.bitwalker.useragentutils.UserAgent])*
or this:
*(:import (nl.bitwalker.useragentutils.UserAgent))*
and you get this error:
c:\1\helloworld>lein compile
Compiling helloworld.core
Exception in thread "main" java.lang.RuntimeException: No such namespace:
UserAgent, compiling:(helloworld/core.clj:7)
at clojure.lang.Compiler.analyze(Compiler.java:6281)
at clojure.lang.Compiler.analyze(Compiler.java:6223)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3497)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6457)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyze(Compiler.java:6223)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3548)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6457)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyze(Compiler.java:6223)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5618)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5054)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3674)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyze(Compiler.java:6223)
at clojure.lang.Compiler.compile1(Compiler.java:7030)
at clojure.lang.Compiler.compile(Compiler.java:7097)
at clojure.lang.RT.compile(RT.java:387)
at clojure.lang.RT.load(RT.java:427)
at clojure.lang.RT.load(RT.java:400)
at clojure.core$load$fn__4890.invoke(core.clj:5415)
at clojure.core$load.doInvoke(core.clj:5414)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5227)
at clojure.core$compile$fn__4895.invoke(core.clj:5426)
at clojure.core$compile.invoke(core.clj:5425)
at user$eval31.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6511)
at clojure.lang.Compiler.eval(Compiler.java:6501)
at clojure.lang.Compiler.eval(Compiler.java:6477)
at clojure.core$eval.invoke(core.clj:2797)
at clojure.main$eval_opt.invoke(main.clj:297)
at clojure.main$initialize.invoke(main.clj:316)
at clojure.main$null_opt.invoke(main.clj:349)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: No such namespace: UserAgent
at clojure.lang.Util.runtimeException(Util.java:170)
at clojure.lang.Compiler.resolveIn(Compiler.java:6736)
at clojure.lang.Compiler.resolve(Compiler.java:6710)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6671)
at clojure.lang.Compiler.analyze(Compiler.java:6244)
... 46 more
Compilation failed.
The error doesn't help you solve the problem... which is: don't pass a seq
to :import
Thank you HH.
On Wed, Oct 24, 2012 at 2:58 PM, Herwig Hochleitner
<[email protected]>wrote:
> 2012/10/24 Andrii V. Mishkovskyi <[email protected]>
>
>> lein deps runs just fine, but trying to import the package in the
>> namespace fails with the following exception:
>> "java.lang.ClassNotFoundException:
>> nl.bitwalker.useragentutils.UserAgent". Here's the complete
>> helloworld/core.clj listing:
>>
>> (ns helloworld.core
>> (:import [nl.bitwalker.useragentutils UserAgent])
>> (:gen-class :main true))
>>
>>
> Not sure why that doesn't work. The idimatic form, however, is either:
>
> (ns ... (:import pgk.ClassName))
>
> or the prefix list form with round parens
>
> (ns ... (:import (pkg ClassNameA ClassNameB ...)))
>
>
>> Now, changing the import to look like (:import
>> [nl.bitwalker.useragentutils.UserAgent]) actually makes the compile
>> succeed, but then I have no idea how to access UserAgent class, since
>> neither (UserAgent. ) nor (nl.bitwalker.useragentutils/UserAgent. ) works
>> when trying to compile the project.
>>
>>
> The constructor takes a String argument. There is also a static factory,
> which is IMO preferrable:
> http://user-agent-utils.java.net/javadoc/nl/bitwalker/useragentutils/UserAgent.html#parseUserAgentString(java.lang.String)
>
> call like (UserAgent/parseUserAgentString "uas")
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
--
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en