Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a very simple clojure function from Java does not work
    primarykey
    data
    text
    <p>I'm very new in learning Clojure. This intended to be my first and very simple Clojure tries in which I call a simple Clojure method from inside java code. Unfortunately it does not work. The Compilation is successful and from the Clojure REPL the written function does as it was ordered, but when calling from Java it says the following:</p> <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Wrong number of args (2) passed to: ClojNum$-myinc at clojure.lang.AFn.throwArity(AFn.java:439) at clojure.lang.AFn.invoke(AFn.java:43) at com.experimental.clojure.test.ClojNum.myinc(Unknown Source) at com.experimental.clojure.java.JavaCaller.main(JavaCaller.java:14) </code></pre> <p>Here is the very simple Clojure code:</p> <pre><code>(ns com.experimental.clojure.test.ClojNum (:gen-class :init init :name com.experimental.clojure.test.ClojNum :methods [ [myinc [int] int] ])) (defn -init [] [[] (atom [])]) (defn myinc "comment" [x] (+ x 1)) (defn -myinc "comment" [x] (myinc x)) </code></pre> <p>And the java part:</p> <pre><code>package com.experimental.clojure.java; import com.experimental.clojure.test.ClojNum; public class JavaCaller { /** * @param args */ public static void main(String[] args) { int i = 0; System.out.println(i); ClojNum c = new ClojNum(); i = c.myinc(0); System.out.println(i); } } </code></pre> <p>What did I do wrong? (Note again: This is primitve test code just to make a first successful function call)</p> <p>Thanks for the help, I'm clueless.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload