I'm trying to explore URL data capabilities to embed in HTML Java applet.
The documentation, for HTML tags to instantiation a java applet 1, don't exclude this option but I don't seem to be able to to this.
I have different variations of HTML tags values using (object and applet) and what I think came close to my goal was this:
<object type="application/x-java-applet" width="100" height="100">
<param name="archive" value="data:application/java-archive;base64,BASE64_OF_JAR"/>
<param name="code" value="test.class"/>
<h1>not working</h1>
</object>
This variation result in an IlegalArgumentException with text "name". I check this clicking on the Error Icon on the Browser. On The java console the whole stack trace is:
java.net.MalformedURLException: unknown protocol: data
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.ProgressMonitorAdapter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupProgress(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Does anyone have an idea about how to do this or if it's not possible?
PS: There's an example of how to embed an JNLP in HTML by Oracle here
A Java applet can be executed from a Web browser. The class name must be the same as the file name that contains the class. A file may contain several classes. Each class in the file is compiled into a separate bytecode file.
Applet is embedded in an HTML page (in much the same way as images, audios, videos and other programs are embedded in an HTML file). To run an applet, you need to create a HTML file, which embeds the applet. Use a text editor to create the following HTML file and save it as " HelloApplet.
The HTML <applet> tag specifies an applet. It is used for embedding a Java applet within an HTML document.
The HTML4 specification for OBJECT element allows inline data embed through URL DATA and the Applet instantiation documentation from Oracle also allows this. The tests performed show the Java browser plugin (from Oracle), and the available source code from Java SE 6, shows that the implementation doesn't support it.
In this case, doesn't seem to matter if the browser support it, because the resource handling of resources reference in the Object/Applet HTML Element are performed by the browser plugin.
An alternative would be to be use applet deserialization, serialized through URL DATA, using the OBJECT attribute of APPLET element. As mentioned in the HTML4 specification, there is no active support for APPLET and OBJECT attribute, and JRE doesn't seem to support Object deserialization from URL DATA too.
In a nutshell, JRE doesn't support base64 deserialization in the CODE, OBJECT and ARCHIVE HTML attributes.
There is also a BUG regarding URL DATA support in JRE1.4.1 that wasn't fulfilled Bug ID: 4756961.
The results of my tests with JRE7 in a 64 bits Windows machine are the following:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With