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, "[email protected]"
<[email protected]> 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?),
> since I should have all rights when the applet is signed. As a
> workaround, I guess, if reflection can be avoided there should be no
> problems when using Clojure within applets.
>
> Bye,
>
> Andi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---