Questions tagged [applet]

Applet means 'small application'. This has become commonly used to describe Java applets embedded in web pages. And in that context, applets can be regarded as outdated technology.

Applet

Applet means 'small application'. This term has become commonly used to describe Java applets embedded in web pages - to the extent that the HTML based applet element is for embedding Java applets.

That being said:

  • An applet does not need to be embedded in a web page
  • An applet does not need to be written in Java
  • Many embedded Java applets are not 'small'

Gradually this term is being dragged back to its original meaning. In the more general sense, it might be applied to (for example) operating system settings or configuration applets. Such OS specific applets would typically not be written using Java.

Having covered the general meaning, and recognizing that the common usage of 'applet' is still 'Java applet', the rest of this entry will focus on Java applets.


Java Applet

Looking from the specific Java applet context, it is important to understand that no modern browser is supporting Java plugins any more; and therefore Java applets are not supported any more, too! This means: Java applets can be seen as a product that has reached "end of life"; it should not be used any more when developing new products; applets are only relevant in the sense of "how to migrate away" from them.

Java applets are applications written using the Java programming language that are embedded in web pages. Applets typically provide dynamic functionality that is not supported by plain HTML or a combination of HTML and JavaScript.

Perhaps ironically, the functionality of JavaScript is sometimes invoked from Java applets to achieve things that applets cannot do on their own. Further, the deployJava.js JavaScript provided by Oracle is designed to launch applets after checking a suitable minimum Java version is installed. While Java can do things that JavaScript cannot - most modern applets would not get very far if JavaScript was disabled in the user's browser!

Many 'beginner books' on Java seem to rush into applet development in early stages in the book. This is a huge mistake. Any text that does so should be considered suspect.

While applets might seem easy to develop, they are actually quite tricky. To deploy an applet reliably to 'all comers' (or at least the vast majority) on the WWW is an order of magnitude more difficult again. For more details See Why CS teachers should stop teaching Java applets, a blog entry by the top ranked provider of answers for the applet tag.

The Java applet API provides methods considered handy to web based applications. These include methods to gain images and audio clips, discover and communicate with other applets, ascertain the code base and document base (where am I?) to allow relative references to resources (images, clips, text files, etc.) that the applet might use.

Applets could be embedded in web pages since Java 1.1. With Java 1.2 came Java Web Start, which could launch both applications and applets as free floating entities (not embedded in a web page). With the release of Java 1.6.0_10, applets could remain embedded in web pages, but they also access the functionality of JWS and services of the JNLP API.

Applet 'Hello World' Example

This example requires the Java Development Kit installed. Visit Java SE Downloads for the latest JDK.

/* <!-- Defines the applet element used by the appletviewer. -->
<applet code='HelloWorld' width='200' height='100'></applet> */
import javax.swing.*;

/** An 'Hello World' Swing based applet.

To compile and launch:
prompt> javac HelloWorld.java
prompt> appletviewer HelloWorld.java  */
public class HelloWorld extends JApplet {

    public void init() {
        // Swing operations need to be performed on the EDT.
        // The Runnable/invokeAndWait(..) ensures that happens.
        Runnable r = new Runnable() {
            public void run() {
                // the crux of this simple applet
                getContentPane().add( new JLabel("Hello World!") );
            }
        };
        SwingUtilities.invokeAndWait(r);
    }
}

See also

7462 questions
2
votes
1 answer

How to pass image from Applet to JSF backing bean

I am working with a web application in which there is a Java Applet that captures an image from a wacom device into a RenderedImage object. The applet itself is embedded into a JSF 2.0 page. I need to pass the created RenderedImage from Applet to a…
Hernan Bernal
  • 39
  • 1
  • 7
2
votes
1 answer

ClassNotFoundException from applet on Java 1.7u25 when certificate revocation check is enabled; working fine on 1.6

I'm using html & jnlp to deploy the applet. The applet is signed by externally generated certificate because it needs all-permissions. It works fine on Java 1.6. On Java 1.7 it throws ClassNotFoundException being unable to find applet's main…
2
votes
3 answers

jcop applet upload error

I'm new to Java card development. I use jcop tools as development kit. When I run simple applet in Eclipse it gives this error. In the run configurations I choose the Java card simulation mode. After successfully installed in simulation mode i want…
Need
  • 97
  • 1
  • 11
2
votes
1 answer

How to write to a file in applets in java?

Since Applets run in sandbox mode in browsers, I am using AccessController.doPrivileged to write to a file. It writes to the file when I run it in Eclipse, but doesn't write when I access the applet in browser. What am I missing? Here is the…
user2536083
  • 21
  • 1
  • 2
2
votes
0 answers

In manifest.mf Trusted-Library: true giving me mixed code prompts

My system contains four jars. One jar contains Mixedcode(applet called from javascript). The jar containing the mixed code accesses other jars also. I added the attribute Trusted-Library : true and Permissions: all-permissions in manifest.mf(I'm…
gusainhimanshu
  • 157
  • 1
  • 11
2
votes
4 answers

Migrate Java Applet to what/where?

I am reviewing currently a medium size code base (around 30K LOC) which uses a huge Applet and interfaces with other systems. It's a tool to create custom labels, so we need drag-n-drop and other related UI components. To which technogly will you…
lud0h
  • 2,370
  • 6
  • 33
  • 41
2
votes
1 answer

Java7 Update21 Applet Issue

I am facing the Issue while running the application with Applets,Could some one please help me regarding this Issue. I am running in IE8 and Java7Update21,Could some one help this Issue. Exception in thread "Thread-15"…
2
votes
1 answer

Applet requests crossdomain.xml

I have web server (IBM Domino), that is using 2 hostnames, because of two different authentication methods. Both serve same application that contain a Java applet that does image upload to a servlet. Problem is that for one hostname it requires…
2
votes
6 answers

java 7 update25 applet not working on IE10

Anyone has success of running applet page below with IE10 installing the jre7u25? http://www.java.com/en/download/testjava.jsp Are there any way to disable update of java when using runapplet…
tompal18
  • 1,164
  • 2
  • 21
  • 39
2
votes
7 answers

Is it worth studying applet?

I am a fresher in web developing , is I ve to study applets?
Karthik.m
  • 771
  • 5
  • 12
  • 20
2
votes
3 answers

Running java applet in ASP.NET MVC application

I have a applet that runs with no issue in asp.net web application ... but when comes to ASP.MVC application ..here applet is not working throwing class not founnd exception please let me know if anyone could able to run applet in MVC application…
batwadi
  • 1,836
  • 7
  • 29
  • 42
2
votes
1 answer

Applet not displaying anything

A simple question with a perhaps not so simple solution. My code is supposed to show a triangle on a black background that can be moved around onscreen. Only nothing displays, just a white area that can't be right-clicked on. It does not work in…
imulsion
  • 8,820
  • 20
  • 54
  • 84
2
votes
0 answers

How to avoid applet security confirmation using policy files

I've made an applet, which requires access to the user's home catalog. First I signed it with a self signed certificate and everything works if the user accepts the applet security prompt. The problem is that the user's who are going to use the…
user979899
  • 141
  • 1
  • 2
  • 14
2
votes
3 answers

Using OO programming to avoid multiple nested if's

I have the following code: public void actionPerformed(ActionEvent e) { String userInput = commandInput.getText(); if (currentLevel == 0) { if (userInput.equals(answers.getIntroAnswers().get(0)) ||…
Adam Short
  • 498
  • 7
  • 28
2
votes
0 answers

How to automate java applet using fest java?

I spent almost entire day on finding the answer of this question. I came to know that I can do this using Fest. I tried to understand how to do it using fest, but unable to understand it. There are not much tutorial available on fest. So can anyone…
narayanpatra
  • 5,627
  • 13
  • 51
  • 60