Search code examples
javaappletgoogle-sites

Embedding Java applets in a Google Sites website


I am trying to run some Java code I wrote in a Google Site I have created. I know there's an issue with this but I tried both of the following options:

  1. Using the Code Wrapper gadget as described here: http://web.michaelchughes.com/how-to/embed-java-applets-in-google-sites. I used the Code Wrapper gadget from the following URL: http://hosting.gmodules.com/ig/gadgets/file/105629041657992777031/code-wrapper.xml with the following Javascript code:

    <script type="text/javascript" src="http://www.java.com/js/deployJava.js"></script>
    
    <script type="text/javascript">
        /* <![CDATA[ */
            var attributes = {
                code: 'com.fusego.wimbeep.applet.ScreamURLApplet.class',
                archive: 'http://sites.google.com/site/wimbeep/technology/wimbeeptools.jar',
                width: 500,
                height: 100
            };
              var parameters = { };
              var version = '1.6';
              deployJava.runApplet(attributes, parameters, version);
        /* ]]> */
    </script>   
    

This does not work - I open a debug console in my Firefox browser and I see that deployJava is undefined.

  1. Using the Embed Gadget with tags:

    <_applet archive="http://sites.google.com/site/wimbeep/technology/wimbeeptools.jar" code="com.fusego.wimbeep.applet.ScreamURLApplet.class" height="400" width="400"/>

This does not work - I see that the JRE starts but there's an error and the console reports the following:

load: class com.fusego.wimbeep.applet.ScreamURLApplet.class not found.
java.lang.ClassNotFoundException: com.fusego.wimbeep.applet.ScreamURLApplet.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassNotFoundException: com.fusego.wimbeep.applet.ScreamURLApplet.class

This is really frustrating. I tried many combination, with and without the .class postfix in the code attribute, it just doesn't work. Any ideas?


Solution

  • I had encountered a similar problem, and I chose the simple expedient of hosting the applet on another site with an ordinary link posted on sites.google.com. Alternatively, this thread suggests loading the applet via , citing this example.

    Addendum: This (somewhat more transparent) example illustrates several approaches.

    • Java Web Start
    • JWS Applet
    • Traditional Applet
    • Downloadable JAR with Manifest