3
votes

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?

2
1. That quoted script is what you should use, but that snippet does not import it. It is imported in both the description you linked to, and the description at Oracle. - Andrew Thompson
You are right of course and I did use that line importing the variable from www.java.com/fs/deployJava.js and it didn't work. For some reason that line was omitted from the post - edited. - smichak
Sigh sites.google.com/site/mysite/technology/myapplets.jar when I clicked that link, it is a 404. When I look at that link, it seems to be anonymized. I don't have time to guess the location of Jars or their content, so here's the deal. Come up with an actual URL for that Jar & the page that is loading it, and I will offer further help.. - Andrew Thompson
Sorry about that. I edited the question with the actual site and package names. I really appreciate you trying to help. Thanks. - smichak
@smichak : I guess to host a JApplet (if you want an easy way), you doesn't have to pay anyone, if your Service Provider allows you to get Domain Names from someone else. Many sites give free Domain Names, check my HomePage, you will get those sites. Though now My computer is the Server, so I have to keep it in ON state, for others to visit my site :-) - nIcE cOw

2 Answers

4
votes

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
2
votes

I saw it 'load without errors' (then do nothing) locally with this HTML:

<html>
<head>
<title>WimBeepTools</title>
</head>
<body>
<applet
    code="com.fusego.wimbeep.applet.ScreamURLApplet"
    archive="wimbeeptools.jar"
    width="500"
    height="100">
</applet>
</body>
</html>

That had the HTML and Jar in the same directory, so load that HTML up at http://sites.google.com/site/wimbeep/technology/applet001.html & the applet should load successfully.

Be sure to add the 001 suffix to ensure we can check other variants in case of initial failure. The page seen by users should be at another URL.

BTW

Use code formatting for HTML

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

Was the initial _ to prevent the site 'swallowing' the HTML? Put HTML (JNLP/XML/Input/Output & source code) in code tags. The applet element was never intended to be 'self-closed' with a />. Add the closing applet element as in my example.

Sort the details first

Ultimately it is best to use the deployJava.js to write the element that embeds the applet when deploying. But first, fix the paths and other attribute details using 'plain old HTML' & the applet element.