This is great, thanks for posting this! I did something just for my
own testing recently, and I have something more useful that is half-
completed, but here is a proof-of-principle clojure app I made. You
may want to take a look at this as it does not require writing any
Java, it is pure Clojure. This compiles to a class file, which you
then use. I had the same security issues as you though, so I'm going
to look over what you did to get around that (type declarations you
say?).
The compile script:
#!/bin/sh -e
base=/home/rob/bin/authored/games/clojure
cd $base
echo "(compile '$1)" | java -cp /home/rob/bin/clojure/clojure.jar:
$base/src:$base/classes: -Dclojure.compile.path=$base/classes
clojure.lang.Repl
The clojure code kitty.clj:
;; Clojure applet proof of principle
;; Author: Robert P. Levy
(ns kitty.kitty
(:import
(java.awt Graphics Frame Color Image Toolkit)
(
java.net URL))
(:gen-class
:extends java.applet.Applet))
(defn -paint [applet g]
(doto g
(.setColor (. Color black))
(.drawString "Hello Kitty!" 60 40)
(.setColor (. Color red))
(.drawOval 40 20 120 30)
(.drawImage (. (. Toolkit getDefaultToolkit) getImage (new URL
"
http://i-love-cartoons.com/snags/clipart/Hello-Kitty/Hello-Kitty-
painting.jpg")) 0 60 applet)
))
The html file HelloKitty.html:
<HTML>
<Head>
<Title>Hello Kitty </Title>
<Body>
View Source: <a href="kitty.clj">kitty.clj</a>
<Applet Code="kitty/kitty.class"
Archive="clojure.jar"
width="500"
height="350">
</Applet>
</Body>
</HTML>
On Oct 13, 5:15 am, "
andi.xeno...@googlemail.com"
<
andi.xeno...@googlemail.com> wrote:
> Hi,
>
> since I found only questions about applets written in Clojure but not
> really answers, I decided to write a small tutorial in the Clojure
> wiki:
http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Creating_an...
> Applet demo:
http://www.xenoage.com/extern/clojurebook/applet/cljapp.html
>
> The good news: It works :-)
> The bad news: It took me some time to find our why I got a
> SecurityException although the applet was signed. By using type hints
> (#^Graphics2D) I could solve the problem. Perhaps this is a JVM bug
> (related tohttp://
bugs.sun.com/view_bug.do?bug_id=6595618or so?),