[armedbear-devel] java/abcl hello-world example

David Dreisigmeyer david.dreisigmeyer at gmail.com
Sat Aug 21 14:26:21 UTC 2010


I'm new to both abcl and java.  I was wondering if someone could provide a
"hello world" example (the more details the better) where I write the
program in java, create a jar file, and then use that from the repl? An
example of what I'd like to do using Clojure is (see
http://pramode.net/clojure/2010/05/01/clojure-java-interop/ ):

1) counter.java:

package demo
public class counter{
        int c = 0;
        public void increment()
        public int get()
                return c;
        public static int sqr(int x)
                return x*x;

2) Using in Clojure:

; To get this to run in SLIME do the following (where we're in demo/ to start):

;; > javac counter.java
;; > cd ../
;; > jar cvf demo.jar demo
;; > mv demo.jar lib/
;; Remember we were in demo/ to start. The directory lib/ is created when we
;; run lein new. So now we have the jar file we created placed with all of the

;; other jar files on the classpath. So we can continue:
;; > lein swank
;; Now start up emacs and M-x slime-connect (accepting and
4005 defaults).
;; At the repl in emacs do
;; user> (import '(demo counter))

;; user> (counter/sqr 4)

Thanks, I really appreciate any help!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20100821/2f85f251/attachment.html>

More information about the armedbear-devel mailing list