Mohammad Areeb Siddiqui
Mohammad Areeb Siddiqui

Reputation: 10179

Are applets now deprecated?

I was reading through a website named w3schools and was taking the HTML5 lesson. There I saw a number of deprecated tags in HTML5 that were before accepted by HTML4. One of its tag were <applet>! So are now applets of no use?

You can see it here: HTML5 New Elements(at the end) or here: enter image description here

Upvotes: 10

Views: 13716

Answers (4)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201528

Applets (as applications written in Java and intended to run inside a browser) are not deprecated in any way in HTML specifications or drafts. There is decreasing interest in them, due to many other alternatives being available, but that’s a different issue.

The applet element was declared deprecated in HTML 4, in favor of the object element. In HTML 4, deprecation means that element is still part of the language, browsers are recommended to support it (though in practice, not all browsers support it, and some browsers could not support it), but there is a recommendation to use something else (in this case, object) instead of it.

In HTML5 CR, the word “deprecated” is not used. It uses the term “obsolete”, which means in principle something quite different but comes very close in practice. In HTML5 CR, the applet element is declared “entirely obsolete and non-conforming”, with the note that it “must not be used by authors”. Yet, HTML5 contains a definition of applet under “Requirements for implementations”. And HTML5 conformance requirements specify that normal browsers must (not just should) support it.

One of the few real differences between the HTML 4 concept “deprecated” and the HTML5 concept “obsolete” is in validation: when validating against an HTML 4 DTD, applet is accepted when the Transitional DTD is used (but flagged as an error when validating against the Strict DTD); in HTML5 validation, applet is reported as an error.

P.S. W3schools should not be used as any kind of authority or reference, see http://w3fools.com


UPDATE 2021 - Applets were officially deprecated by Oracle in Java 9. So while W3Schools were not strictly correct at the time that this article was written, what they said then is correct ... now.

The main reason that Oracle gave for deprecating Applets was that most modern web browsers have stopped supporting them. As of right now, (AFAIK) only Internet Explorer still supports Applets, and IE is due to go EOL in mid 2022.

Upvotes: 14

Mehdi LAMRANI
Mehdi LAMRANI

Reputation: 11597

Applet deprecated in Java 9

Applets are deprecated in Java 9. Oracle will stop distributing and supporting the Java browser plug-in.

Quoting from the java.applet.Applet class:

The Applet API is deprecated. See the java.applet package documentation for further information.

See this blog post from Oracle for more info: Moving to a Plugin-Free Web

Consider Java Web Start technology.

Upvotes: 4

They are still of use, but use the object tag instead. Example:

<object
    width  = "800"
    height = "510"
    data   = "http://math.hawaii.edu/~ralph/Classes/Plotting/fplotter.jar"
    type   = "application/x-java-applet"
>
    <param
        name  = "codebase"
        value = "http://math.hawaii.edu/~ralph/Classes/Plotting/"
    />
    <param
        name  = "code"
        value = "a_fplotter.class"
    />
    <param
        name  = "width"
        value = "800"
    />
    <param
        name  = "height"
        value = "510"
    />
    <param
        name  = "archive"
        value = "fplotter.jar"
     />
</object>

Upvotes: 6

Benjamin Gruenbaum
Benjamin Gruenbaum

Reputation: 276286

Disregarding whether or not applets are a good idea,

Use the <object> element instead. That's the standards complaint way.

The object element can represent an external resource, which, depending on the type of the resource, will either be treated as an image, as a nested browsing context, or as an external resource to be processed by a plugin.

Upvotes: 3

Related Questions