How to run or embed an applet
The previous page showed the skeleton for a basic Java applet
from the point of view of the code itself. But we still haven't seen how to run a Java applet,
which usually means how to embed the applet in a web page. For this, the procedure is usually
- compile the applet into a jar, using the jar tool supplied
with the JDK;
- put the jar next to the HTML file of the web page
(i.e. in the same directory) in which the applet will be embedded;
- include an appropriate applet tag in your web page's HTML definition.
Compiling the jar
A jar or Java archive is essentially a glorified ZIP file (in fact,
it is a ZIP file) containing
your Java classes plus other resources used by the applet or application.
If you enjoy this Java programming article, please share with friends and colleagues. Follow the author on Twitter for the latest news and rants.
Editorial page content written by Neil Coffey. Copyright © Javamex UK 2021. All rights reserved.