Hi Dan, you need to include an arg for "this" in -fooMeth, i.e

(defn -fooMeth [this] "fooMeth")
or
(defn -fooMeth [_] "fooMeth")

- Rgds, Adrian

On Sun, Feb 28, 2010 at 12:06 AM, Dan Becker <db19...@gmail.com> wrote:
> Hi,
>
> I'm trying to write a java class in clojure, and then call it from
> java. But I keep getting IllegalArgumentExceptions.
>
> file hello.clj:
> (ns hello
>    (:gen-class
>     :methods [ [fooMeth [] String]])
>    )
>
> (defn -fooMeth [] "fooMeth")
>
> file TestIt2.java:
>
> public class TestIt2 {
>
>    public static void main(String argv[]) {
>        hello h = new hello();
>        System.out.println(h.fooMeth());
>    }
> }
>
> I compile this in clojure:
> c:\Users\dan\workspace\genc>java -cp .;.\classes;clojure.jar -
> Dclojure.compile.p
> ath=classes clojure.main
> Clojure 1.1.0
> user=> (compile 'hello)
> hello
> user=>
>
> The java code compiles fine, but when I try to run it I get an error:
> c:\Users\dan\workspace\genc>javac -cp .;.\classes;clojure.jar
> TestIt2.java
>
> c:\Users\dan\workspace\genc>java -cp .;.\classes;clojure.jar
> TestIt2
> Exception in thread "main" java.lang.IllegalArgumentException: Wrong
> number of a
> rgs passed to: hello$-
> fooMeth
>        at clojure.lang.AFn.throwArity(AFn.java:
> 449)
>        at clojure.lang.AFn.invoke(AFn.java:
> 52)
>        at hello.fooMeth(Unknown
> Source)
>        at TestIt2.main(TestIt2.java:
> 5)
>
> What an I doing wrong here? fooMeth takes no arguments and I'm not
> passing it any. So why the exception?
>
> Dan
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to