How to Put a Java Application Into a Web Page

Written by joe wandy
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Put a Java Application Into a Web Page
Web pages can include Java applications to provide additional interactivity. (John Foxx/Stockbyte/Getty Images)

Java is a popular programming language. Normally, it is used to create applications that run on desktops, servers or embedded systems. However, Java applications also can run on Web pages. This type of Java application is called an applet. A Web browser with the appropriate Java plug-in can display applets as part of a Web page. This allows Java applications that have been created as applets to be easily distributed over the Internet.

Skill level:

Other People Are Reading

Things you need

  • Java Development Kit
  • Web browser with appropriate Java plug-in

Show MoreHide


  1. 1

    Use the Java Development Kit to create an applet class. An applet class is similar to a normal Java class, but it extends from a parent class called the "java.applet.Applet" class. This will provide the applet class with additional mechanisms to communicate with Web browsers and interact with Web users. Alternatively, extend the applet from a parent class called the "javax.swing.JApplet" class if you wish to construct the graphical user interface of the application using Swing components.

  2. 2

    Deploy the applet class. Compile the applet class and package along with the necessary resources as a JAR file. The JAR file is a combination of the compiled class file and all its related resources into a stand-alone compressed file. Using a JAR file provides the benefits of security, efficiency, versioning and portability and is recommended by Oracle as a method of deploying Java applications on a Web page.

  3. 3

    Create a JNLP file descriptor. JNLP stands for Java Network Launch Protocol and specifies how an applet can be run in the Web page by the Web browser.

  4. 4

    Create the Web page to contain the applet. Add a script in the Web page to call the Deployment toolkit. This specifies which applet to run, the width and height of the applet on the Web page and the associated JNLP file. The following is an example of the script call in the Web page:


    &lt;script src=""&gt;&lt;/script&gt;
        var attributes = { code:'components.DynamicTreeApplet',  width:300, height:300} ;
        var parameters = {jnlp_href: 'dynamictree-applet.jnlp'} ;
        deployJava.runApplet(attributes, parameters, '1.6');


  5. 5

    Test the applet to ensure that it displays successfully in a Web page. Place the JAR, JNLP and Web page files in the same folder. Display the Web page using a Web browser that already has the appropriate Java plug-in installed. Programmers can also check the Java Console messages for debugging and error reporting purposes.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.