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
680
votes
26 answers

Unsupported major.minor version 52.0

Pictures: Command Prompt showing versions Picture of error Hello.java import java.applet.Applet; import java.awt.*; public class Hello extends Applet { // Java applet to draw "Hello World" public void paint (Graphics page) { …
user3397452
  • 6,961
  • 4
  • 14
  • 10
141
votes
17 answers

How can I open Java .class files in a human-readable way?

I'm trying to figure out what a Java applet's class file is doing under the hood. Opening it up with Notepad or Textpad just shows a bunch of gobbledy-gook. Is there any way to wrangle it back into a somewhat-readable format so I can try to figure…
cpuguru
  • 3,763
  • 5
  • 33
  • 31
81
votes
4 answers

Java unsupported major minor version 52.0

I can not launch my java application as a web applet in HTML (I am using HTML 4.01, I know it doesn't work in html5). The error message it returns is: java : Unsupported major.minor version 52.0 I have tried downgrading my java JRE/JDK/SDK but I…
user3329290
71
votes
5 answers

socket programming multiple client to one server

How do you handle multiple client to connect to one server? I have this LogServer.java import javax.net.ssl.*; import javax.net.*; import java.io.*; import java.net.*; public class LogServer { private static final int PORT_NUM = 5000; public…
Harts
  • 4,023
  • 9
  • 54
  • 93
68
votes
1 answer

What is the meaning of the "Application Requires iPhone Environment" key in info.plist?

I'm having trouble understanding the specific requirements in the info.plist file in my app. Should I change it at all, or are the default settings typically the "correct" options? Specifically, the entry: APPLICATION REQUIRES IPHONE ENVIRONMENT If…
waylonion
  • 6,866
  • 8
  • 51
  • 92
65
votes
16 answers

Java applet manifest - Allow all Caller-Allowable-Codebase

As of Java 7u45 an applet will display a warning message (even if signed with a trusted cert) if a webpage tries to interact with it via javascript and that page isn't listed in the manifest's Caller-Allowable-Codebase attribute. Release notes about…
William W
  • 1,776
  • 6
  • 21
  • 40
62
votes
10 answers

Java Error: "Your security settings have blocked a local application from running"

I'm trying to run this simple HelloWorld code written in Java from my browser (Chrome): public class HelloWorld extends JApplet { public void init() { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { …
user2279697
  • 713
  • 1
  • 6
  • 10
59
votes
20 answers

java.io.IOException: Invalid Keystore format

Does anyone know how to solve this? I tried many things, but none of them worked. And when I click more details I get this: at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source) atsun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown…
Tomi
57
votes
7 answers

How do you debug Java Applets?

Currently, the only information I have is a one-line error message in the browser's status-bar. Do you know how I could get a stack-trace for example ?
zimbatm
  • 9,348
  • 4
  • 20
  • 11
56
votes
15 answers

Where did all the java applets go?

When java was young, people were excited about writing applets. They were cool and popular, for a little while. Now, I never see them anymore. Instead we have flash, javascript, and a plethora of other web app-building technologies. Why don't…
Tyler
  • 28,498
  • 11
  • 90
  • 106
50
votes
4 answers

-tsa or -tsacert timestamp for applet jar self-signed

When I was trying to self-sign in the jar like below. jarsigner -keystore my keystore myjar.jar myalias It gives warning like: No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate…
Raja Peela
  • 1,366
  • 2
  • 14
  • 26
50
votes
7 answers

.class vs .java

What's the difference between a .class file and a .java file? I am trying to get my applet to work but currently I can only run it in Eclipse, I can't yet embed in HTML. Thanks **Edit: How to compile with JVM then?
Devoted
  • 177,705
  • 43
  • 90
  • 110
49
votes
2 answers

Java applet can't open files under Safari 7 (Mac OS X 10.9)

We have a web app that uses Java applet to manipulate files on local disk. We develop it for quite a while and we already know all types with issues an applet may have with modern OS'es and browsers and latest Java versions and new security…
JetLizard
  • 639
  • 1
  • 5
  • 8
40
votes
6 answers

How do I sign a Java applet for use in a browser?

I'm trying to deploy a Java applet on my website. I also need to sign it, because I need to access the clipboard. I've followed all the signing tutorials I could find but have not had any success. Here is what I've done so far: Wrote an applet…
user107312
  • 455
  • 1
  • 7
  • 8
40
votes
7 answers

How to combine two Jar files

Is it possible to combine two jar files such that in an applet tag I can simply do something like archive="jarjar.jar/jar1.jar"... ...archive="jarjar.jar/jar2.jar"... instead of archive="jar1.jar"... ...archive="jar2.jar"... I need to only have…
Tony
  • 444
  • 1
  • 4
  • 9
1
2 3
99 100