Instructions
1.
1
Install the tools that will let you build Java programs. Create a folder under your C drive and name it '"jdk." Visit the Sun Microsystems website and download the Java Development Kit (JDK) and the Java Runtime Environment (JRE) to that folder. Install these packages.
2.
2
Type the following source code on a Notepad:
import java.awt.*;
import java.applet.Applet;
public class MyFirstApplet extends Applet {
public void paint (Graphics g) {
g.drawString("This is my first Applet!!!", 100, 25);
}
}
Save the test file as "C:\MyFirstApplet.java."
3.
3
Compile the Java source code. This produces the Java applet. Click Start. Select Run. Type: "javac C:\MyFirstApplet.java". This will create file, 'MyFirstApplet.class'. It is your Java applet.
4.
4
Embed your Java applet into Hypertext Markup Language (HTML) code so you can see it through a browser. Open Notepad and type the following HTML script (replace starting and closing quotation marks with carrots):
"HTML"
"HEAD"
"TITLE"My First Applet"/TITLE"
"BODY"
"CENTER"
"APPLET CODE = 'MyFirstApplet.class' WIDTH = 100 HEIGHT = 25 "/APPLET"
"/CENTER"
"/BODY"
"/HTML"
Save it as, "C:\MyFirstApplet.html."
5.
5
Launch your default browser. Type, "C:\MyFirstApplet.html" in the URL space. Verify that you see "This is my first Applet!!!" in a rectangle in the middle of your browser page.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment