Questions tagged [clojure-java-interop]

For topics related to interoperability between Clojure and Java

Programs written in Java and in Clojure run on the JVM and can therefore call each other. Use this tag to mark questions related to this interoperability.

269 questions
5
votes
1 answer

pom.xml maven properties in leiningen project.clj

I use the $ lein pom command to genereate a maven pom.xml from a Leiningen project.clj file. I do that because I have Java source files in my Clojure project. I would like to make sure the following maven properties are embedded into the generated…
erdos
  • 3,135
  • 2
  • 16
  • 27
5
votes
2 answers

Stuck with type hints in clojure for generic class

I am trying to get a small example from Apache flink running in clojure, but right now I am stuck, because of the type hinting in clojure and some strange quirk in flink. Here is my code: (ns pipeline.core (:import (org.apache.flink.api.java…
5
votes
1 answer

How do I call a Clojure function that takes a two-dimensional array of Strings from Java?

Basically question says it all. When I declare a function signature in gen-class, what type do I put for a 2D array of strings? [myFunc [XXXX] ReturnType] what do I put for XXXX? Update : following @Mark Topolnik's suggestion, I'm trying #^{:static…
interstar
  • 26,048
  • 36
  • 112
  • 180
5
votes
2 answers

Clojure optimization of java interop

When working with existing java classes I often get reflection warnings if I've done something incorrectly, e.g. IllegalArgumentException No matching field found: gets for class java.lang.String clojure.lang.Reflector.getInstanceField …
Steve B.
  • 55,454
  • 12
  • 93
  • 132
5
votes
2 answers

Clojure Leining REPL OutOfMemoryError Java heap space

I am trying to parse a fairly small (< 100MB) xml file with: (require '[clojure.data.xml :as xml] '[clojure.java.io :as io]) (xml/parse (io/reader "data/small-sample.xml")) and I am getting an error: OutOfMemoryError Java heap space …
Nicolas M.
  • 789
  • 1
  • 13
  • 23
5
votes
2 answers

Clojure and JavaFX 2 -- passing multiple-arity arguments to JavaFX methods

A lot of JavaFx methods take var args, such as Group, which is declared in Java as: public Group(Node... children) Others for example: public KeyFrame(Duration time, KeyValue... values) I've discovered the ... means I should pass a java array to…
Sonicsmooth
  • 2,673
  • 2
  • 22
  • 35
5
votes
3 answers

How do you configure proprietary dependencies for Leiningen?

We're working on a project that has some Clojure-Java interop. At this point we have a single class that has a variety of dependencies which we put into a user library in Eclipse for development, but of course that doesn't help when using Leiningen…
tjb1982
  • 2,257
  • 2
  • 26
  • 39
5
votes
1 answer

Sandwiching Clojure between Java with Leiningen

For a class, I need to write some JVM code, and I'm hoping to use Clojure. I got it to work with the bottom part of the software stack, but I can't manage to make it work in between the GUI layer sitting on top and the bottom part. My main problem…
kwenholz
  • 163
  • 7
5
votes
3 answers

Interop from clojure a with non-standard iterative java API

I am working in clojure with a java class which provides a retrieval API for a domain specific binary file holding a series of records. The java class is initialized with a file and then provides a .query method which returns an instance of an…
Alex Stoddard
  • 8,244
  • 4
  • 41
  • 61
4
votes
2 answers

clojure java interop for com.google.cloud.storage.StorageImpl

Trying to do some java interop with https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java#L139 - the create method with a byte array. I have in…
Hoopes
  • 3,943
  • 4
  • 44
  • 60
4
votes
2 answers

How to distinguish java map from clojure map?

Let's say I have the following code: (def m1 (java.util.HashMap.)) (def m2 (java.util.LinkedHashMap.)) (def m3 {}) I need a function that will allow me to detect maps that came from java, e.g.: (map java-map? [m1 m2 m3]) ;; => (true true…
OlegTheCat
  • 4,443
  • 16
  • 24
4
votes
1 answer

How to merge two hashmaps on Clojure?

How can I merge two hashmap variables, for example map1 and map2? I have tried (merge map1 map2), but I got the following exception: ClassCastException java.util.HashMap cannot be cast to clojure.lang.IPersistentCollection
zhanbo_kz
  • 85
  • 5
4
votes
2 answers

How to explore Java methods through REPL

I am playing with Clojure and Java Interop and I came up with the following to inspect the methods of some instance: (defn methods-of [instance & [string]] {:pre [(nil? instance)]} (filter #(re-find (re-pattern (or string #".*")) %) (map…
Andrea Richiardi
  • 703
  • 6
  • 21
4
votes
2 answers

How to create a multipart request in clojure using clj-http api

I want to create a multipart HTTP request using clj-http. Multipart request is below: --Boundary Content-Type: text/xml; charset=UTF-8 Content-Id id1 xml1 --Boundary Content-Type: text/xml; charset=UTF-8 Content-Id id2 xml2 --Boundary-- I am…
Jitendra
  • 51
  • 3
4
votes
2 answers

Clojure annotations and Integers

I am adding Swagger annotations to JaxRs annotated services. I have the following: (^{ GET true Path "/{who}" ApiOperation {:value "Get a hello" :notes "simple clojure GET"} Produces ["text/plain; charset=UTF-8"] ApiResponses {:value…
mbedoian
  • 41
  • 2
1 2
3
17 18