Embedding Java applets in a Google Sites website
-
03-06-2021 - |
Frage
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:
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.
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?
Lösung
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 java-web-start, citing this example.
Addendum: This (somewhat more transparent) example illustrates several approaches.
- Java Web Start
- JWS Applet
- Traditional Applet
- Downloadable JAR with Manifest
Andere Tipps
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.