Deploying A .jar Into A Html Page
Solution 1:
Reference Deploying An Applet In Under 10 Minutes :
Compile / build your applet's Java code and make sure all class files and resources such as images etc. are in a separate directory, example
build/components.Create a
jarfile containing your applet's class files and resources.cd buildjar cvf DynamicTreeDemo.jar componentsSign your
jarfile if the applet needs special security permissions, for example, to be launched in a modern JRE with default settings. By default, unsigned code will be blocked.jarsigner -keystore myKeyStore -storepass abc123 -keypass abc123 DynamicTreeDemo.jar johndoewhere keystore is setup and located at "myKeyStore" alias is "johndoe" keystore password and alias password are "abc123"
Create a
JNLPfile that describes how your applet should be launched.
dynamictree-applet.jnlp
<?xml version="1.0" encoding="UTF-8"?><jnlpspec="1.0+"codebase=""href=""><information><title>Dynamic Tree Demo</title><vendor>Dynamic Team</vendor></information><resources><!-- Application Resources --><j2seversion="1.6+"href="http://java.sun.com/products/autodl/j2se"max-heap-size="128m" /><jarhref="DynamicTreeDemo.jar"main="true" /></resources><applet-descname="Dynamic Tree Demo Applet"main-class="components.DynamicTreeApplet"width="300"height="300"></applet-desc></jnlp>- Create the HTML page that will display the applet. Invoke the runApplet function from the Deployment Toolkit to deploy the applet.
AppletPage.html
<body>
....
<scriptsrc="http://java.com/js/deployJava.js"></script><script>var attributes = { code:'components.DynamicTreeApplet', width:300, height:300} ;
var parameters = {jnlp_href: 'dynamictree-applet.jnlp'} ;
deployJava.runApplet(attributes, parameters, '1.6');
</script>
....
</body>For this example, place
DynamicTreeDemo.jar,dynamictree-applet.jnlp, andAppletPage.htmlin the same directory on the local machine or a web server. A web server is not required for testing this applet.View `AppletPage.html in a web browser. The Dynamic Tree Demo Applet will be displayed. View Java Console Log for error and debug messages.
For more information see Deployment Toolkit 101 - Java Tutorials Blog
Solution 2:
The Oracle website at this location says:
To start any applet from an HTML file for running inside a browser, you use the applet tag. For more information, see the Java Applets lesson. If the applet is bundled as a JAR file, the only thing you need to do differently is to use the archive parameter to specify the relative path to the JAR file.
It claims that
<appletcode=TicTacToe.classarchive="TicTacToe.jar"width="120"height="120"></applet>is the appropriate html code to display an applet stored as TicTacToe.jar in the same directory as the html file.
Post a Comment for "Deploying A .jar Into A Html Page"