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
0
votes
0 answers

Access scala/spark constructor in clojure

I want to access the constructor from the class StructField which is present in the package org.apache.spark.sql.types as shown in their github repo. So just for testing I imported the classes in clojure like this: (ns user (:import…
Punit Naik
  • 515
  • 7
  • 26
0
votes
2 answers

how to iterate over a list of maps in clojure and concatenate that to a string

I have a list of maps with two keys :path and :size listOfMaps ({:path "a " :size "1 "}{{:path "b " :size " 2"}...) how to iterate over it and concatenate its path and size to a string so that it is in between that is str "initial" "a" "1" "b"…
0
votes
1 answer

Hdfs folder size in Clojure

I have to HDFS folder size which is having sub directories from Clojure. How to use getContentSummary and getSpaceConsumed in Clojure. I know how to do this in Java. FileSystem fs = FileSystem.get(config); Path current = new Path(path); double…
0
votes
2 answers

Java Interop: Why does (.setProperty (Properties.) "key1" "value1") return nil but wrapping the call in a doto works?

The following code returns nil: (.setProperty (Properties.) "key1" "value1") -> nil The following, however, seems to work as intended: (doto (Properties.) (.setProperty "key1" "value1")) -> {"key1" "value1"} Why is that?
mss
  • 35
  • 5
0
votes
1 answer

Clojure : call a superclass method

I have a big problem that I couldn't solve and I really do not find the error. I want to use this function : http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/optim/univariate/BrentOptimizer.html The sample Test code…
Joseph Yourine
  • 1,301
  • 1
  • 8
  • 18
0
votes
2 answers

Calling java.lang.String .split methode in clojure

When i call the .split methode in clojure i get: #object["[Ljava.lang.String;" 0x5aaf6982 "[Ljava.lang.String;@5aaf6982"] #object["[Ljava.lang.String;" 0x18fbbda2 "[Ljava.lang.String;@18fbbda2"]. How can i use this object in my code?
user4813927
0
votes
0 answers

wait until a download completes before calling a function in clojure

I am using a webdriver to navigate to a webpage and download a json file. I need to wait for completion (or failure, at which I will give the user a message) for the file to download before I can call the function that will pull in the data to the…
0
votes
1 answer

Mapping a Java native function to an array of char results in exception

So I was trying this: user=> (Integer/toBinaryString ^int (.charValue \c)) "1100011" user=> And I thought... Well, that looks promising, so let's try this now: user=> (map #(Integer/toBinaryString ^int (.charValue %)) "some") ClassCastException…
dsm
  • 10,263
  • 1
  • 38
  • 72
0
votes
1 answer

Import Java Code in Clojure - Protocol Buffer

I have a JAR with a class Proto$Event.class (compiled from Protocol Buffer). Now I want to use it in a Clojure Project. I include the JAR on my clojure project following this steps. But I am not be able to run this code in clojure: (ns…
Édipo Féderle
  • 4,169
  • 5
  • 31
  • 35
0
votes
1 answer

Getting the same instance of RandomAccessFile in clojure

This piece of code runs on the server and it detects the changes to a file and sends it to the client. This is working for the first time and after that the file length is not getting updated even the I changed the file and saved it. I guess the…
0
votes
1 answer

How do I use java interop to get screen size in Clojure?

How do I get screen size in Clojure? I'm having trouble using Java interop. A demonstration of Toolkit.getScreenSize() would be most useful to me. I've tried (.getScreenSize Toolkit) after importing the appropriate library and similar stuff…
Pointo Senshi
  • 541
  • 5
  • 17
0
votes
0 answers

Using clojure in android

I have written a clojure program that performs data manipulations of some complexity. I would like to bring this functionality to my phone. As an alternative to having to reimplement the whole code in java, I thought it would be nice to use clojure…
Gerrit Begher
  • 363
  • 2
  • 14
0
votes
1 answer

How do I implement this generic Java interface with a Clojure record?

I'm trying to implement org.joda.time.ReadableInstant. It inherits from a generic interface, but apparently that shouldn't matter. The interface is: public interface ReadableInstant extends Comparable { long getMillis(); …
Joe
  • 46,419
  • 33
  • 155
  • 245
0
votes
1 answer

cast class to SensorEventListener

I'm trying to register SensorEventListener but my listener has wrong type. Here's what I tried: ;; listener (gen-class :name com.spython.pushupcounter.main.sensor-listener :implements [android.hardware.SensorEventListener] :prefix "-" :methods…
ivknv
  • 305
  • 1
  • 4
  • 14
0
votes
1 answer

can't access getSystemService

I'm trying to call getSystemService (method of Activity) to access sensors, but looks like it doesn't exist. Here's the code I tried: (in-ns 'com....) ; Some Neko project (.getSystemService a) ; a is :def of Activity I even checked all the methods…
ivknv
  • 305
  • 1
  • 4
  • 14
1 2 3
17
18