beoliver
beoliver

Reputation: 5759

Clojure importing nested classes

I am trying to write a couple of wrapper functions for the code here

it basically has the form (as given in the example page) of

String json = ...
VPackParser parser = new VPackParser.Builder().build();
VPackSlice slice = parser.fromJson(json);

I am aware that To import inner classes one uses $, but every combination of the following doesn't seem to work.

(ns the.pain.is.real
  (:require [clojure.reflect :as r])
  (:import
   com.arangodb.velocypack.VPackBuilder ;; fine
   com.arangodb.velocypack.VPackSlice ;; fine
   com.arangodb.velocypack.VPackParser ;; fine
   com.arangodb.velocypack.VPack ;; fine
   com.arangodb.velocypack.VPackParser$Builder ;; nope
))

I just get a Unhandled java.lang.ClassNotFoundException.

I had worked with some similar code that I had got working using:

(ns winning
  (:import com.arangodb.ArangoDB$Builder))
(.build (-> (new ArangoDB$Builder)
            (.host "127.0.0.1" 8529)
            (.user username)
            (.password password)))

Any ideas?

looking in the jar file does show

com/arangodb/velocypack/VPackParser$Builder.class

Is it just trial and error?

Upvotes: 3

Views: 653

Answers (1)

beoliver
beoliver

Reputation: 5759

Answering my own question.

It appears that two versions were downloaded when using lein deps. Even though only [com.arangodb/velocypack "1.0.0"] was in the project file, both 1.0.0 and 1.0.10 were in the .m2 dir. The class com/arangodb/velocypack/VPackParser$Builder.class is only found in version 1.0.10.

After changing the project file to [com.arangodb/velocypack "1.0.10"] the import works.

Upvotes: 3

Related Questions