Step 1: Create a page on your Google site to hold the .class files. I made a "file cabinet" page and then simply uploaded all of the .class files there.
Step 2: Prepare your HTML snippet. Here is what I used. Notice that I set the
CODEBASE
to the directory that is associated with the "file cabinet" page. I needed to do this because my Applet used multiple .class files. If you only had one .class file you could put the absolute address to that class file with the CODE
attribute and leave out the CODEBASE
attribute.<APPLET CODE="DancingStickFigureApplet.class"
WIDTH=400
HEIGHT=350
CODEBASE="http://sites.google.com/site/compsci/dancing-stick-figure/applet-files/"
ALT="Your browser understands the <APPLET> tag but isn't running the applet, for some reason.">
Your browser is ignoring the <APPLET> tag!
</APPLET>
Step 3: Put the Applet into the page. DO NOT PASTE THE APPLET HTML INTO THE PAGE. A Google site page does not allow this. Instead, you need to embed it as a gadget. While your page is open for editing, select Insert-->More Gadgets. You are looking for the gadget called “Embed Gadget.” I found it faster by selecting “Featured Gadgets.” Paste in the Applet code into the gadget dialog box and you are done!
Here is my web page showing a working Applet with a dancing stick figure. :-)
thanks a lot sir, its working, i used it to put java applets game on google sites
ReplyDeleteHi,
ReplyDeleteTrying to load the demo page you linked above, I get an error of:
"incompatible magic value 1011373133 in class file DancingStickFigureApple"
This happens also when I try the method you descibe above with an applet of my own.
Do you have any idea how to solve this?
I'm using both FF & IE9 to test this.
Thanks,
Ilan
It took me quite a while to figure out what I was doing wrong, and it turned out I was using "http://" rather than "https://". Thank you very much! Super helpful, and much simpler than any other help I've found. Thank you very much!
ReplyDeleteThanks for the post about this topic. Storing the files in a Google Sites file cabinet is not working for me, at least not when my applet tries to load sounds from a JAR that's in the file cabinet on Google Sites. I was seeing access permission errors, with sockets, etc. Googling the error message revealed no hits, and so I enabled full debugging in the Java Runtime console. I saw that Google caches the actual files on different servers (oddly named servers like b1.xyz.googlegroups.com). The failure was occurring in the getAudioClip call... I believe the codebase isn't fixed when you use this approach.
ReplyDeleteWhat I did to make it work was to upload the JAR to a code.google.com repository (it's an extra step to create it). Referring to that space as a codebase from Google Sites is OK.