10

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

Mohammad Areeb Siddiqui
  • 9,795
  • 14
  • 71
  • 113

4 Answers4

14

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
  • 4
    What about Chrome which has stopped support for Applets? – Mangesh Kherdekar Jul 05 '15 at 00:19
  • 1
    While W3schools wasn't great, it's gotten better. W3fools is nothing more than an attempt to bring down w3schools and as far as I've seen, hasn't done anything to contribute a solution. Real developers contribute by providing constructive feedback about any reference material and work together to make something better. – OzzyTheGiant Oct 28 '15 at 14:26
  • 1
    Neither I don´t know why i can't see an applet using Chrome? – Fernando Pie Aug 09 '16 at 16:41
  • 2
    I suspect this answer may need to be updated because I went to Java.com with Edge and Chrome today (IE isn't even exposed in Windows 10 any more), and neither support Java applets any more. – BlueMonkMN Nov 07 '17 at 19:19
  • 1
    See also "Why were applets deprecated in JDK 9?" https://stackoverflow.com/questions/45535112/why-were-applets-deprecated-in-jdk-9 – www-0av-Com Jan 28 '19 at 16:27
6

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>
4

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.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130
3

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.

Community
  • 1
  • 1
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
  • and what does that tag do by thw way? – Mohammad Areeb Siddiqui Jun 09 '13 at 19:42
  • @AreebSiddiqui In the applet use case: The `object` tag does same thing that the `applet` tag did. If you're new to web-coding, I really think Java applets might not be the right place to start and [w3schools might not be the right place to start learning](http://www.w3fools.com). Consider starting with [JavaScript](https://developer.mozilla.org/en-US/learn/javascript), if you'd really like to keep using Java you can use [GWT](https://developers.google.com/web-toolkit/) But I'd recommend against it if you're just starting. – Benjamin Gruenbaum Jun 09 '13 at 19:45
  • well, I am not a starter, I am an MS in exam 070-480 :) – Mohammad Areeb Siddiqui Jun 09 '13 at 19:53