24 July 2009

Embedding Applets in a Web page - 3

Setup the WampServer as explained here
-----------------TestApplet3.java-----------------------
import javax.swing.*;

public class TestApplet3 extends JApplet {
public void init() {
add (new JLabel("Hello World", JLabel.CENTER));
}
}
--------------------------------------------------------
-----------------------test3.html-----------------------
<HTML>
<HEAD>
<TITLE>My new applet page</TITLE>
</HEAD>
<BODY>
<OBJECT
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH="170"
HEIGHT="70"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2_05-windows-i586.cab#Version=1,4,2,5">
<PARAM NAME=CODE VALUE="TestApplet3">
<PARAM NAME=CACHE_OPTION VALUE="plugin">
<PARAM NAME=CACHE_ARCHIVE VALUE="TestApplet3.jar">

<COMMENT>
<EMBED
TYPE="application/x-java-applet;version=1.4.2"
CODE="TestApplet3"
CACHE_OPTION="plugin"
CACHE_ARCHIVE="TestApplet3.jar"
WIDTH="170"
HEIGHT="70">
</EMBED>
</COMMENT>
</OBJECT>
</BODY>
-------------------------------------------------------
----------------------mymanifest-----------------------
Manifest-Version: 1.2
Main-Class: TestApplet3
Created-By: 1.4 (Sun Microsystems Inc.)
-------------------------------------------------------

-------------------------------------------------------
1. Save TestApplet2.java, test2.html and mymanifest inside the website's home page
2. Make sure JRE is installed in the machine.
3. javac TestApplet3.java
4. jar cvfm TestApplet3.jar mymanifest TestApplet3.class
5. del TestApplet3.class
6. http://localhost/test3.html
7. appletviewer -classic test2.html
8. java -jar TestApplet3.jar
-------------------------------------------------------

Reference:
How to make a JAVA application - executable JAR archive:

No comments:

Post a Comment