Monday 29 December 2014

java applet tutorial

Beginners guide in Java Applet Embedding a java applet in HTML page with Example

Modern days programming uses Java as an object oriented programming. Using applet we can use Java program embedded to any web program. Applet also provides data security and data encryption. If you are learning your first applet program then this tutorial is best for you.

 

Step 1: Write A Simple Applet Code in Java

It can be done in two ways:
    • Opening a notepad file in java bin directory and writing source code in it and save it with .java extension. Click here to know how to write a java program.
    • It can also be done from console window. I have used this path: c:\Programfiles\java\jdk1.7.0_06\bin\edit filename .java

Java Applet Sample Code:


 Step 2: Compile The Java Source Code

To compile the java file write the following code to console/command prompt c:\Programfiles\java\Jdk1.7.0_06\bin>javac first Applet .java after the compilation of the first Applet.java a first Applet.class file will be generated to your directory, i.e. a platform independent byte code you will get.

Step 3: Create a HTML Page That References Applet

Step 4: Display The Applet In HTML Page

Display the Applet can be done in two ways.

    • Open the created (i.e. firstApplet.html) html page with the browser 
    • Opening from the command prompt (console) c:\Programfiles\java\Jdk1.7.0_06\bin>applet viewer firstApplet.html 
Hope you have learn ed your first applet programming from this tutorial.

 
Posted in:

0 comments:

Post a Comment