小程序已正式消失,但浏览器中的Java更好。
Applets Are Officially Gone, but Java in the Browser Is Better

原始链接: https://frequal.com/java/AppletsGoneButJavaInTheBrowserBetterThanEver.html

## Java Applet 的终结与现代 Java Web 开发的兴起 Java Applet 是一种可以实现交互式网页内容的古老技术,其历史可以追溯到 1996 年,将于 2026 年 3 月的 Java 26 中正式移除。 尽管曾经具有革命性意义,但浏览器在 2000 年代已经放弃了插件支持,从而阻碍了 Applet 的功能。 然而,Java 在 Web 上的存在并未消失。 像 **TeaVM** 这样的工具允许开发者将 Java 代码直接*转换*成高效的 JavaScript 或 WASM,从而在无需插件的情况下实现快速、高性能的 Web 应用程序。 TeaVM 处理代码压缩、优化和浏览器 API 集成。 对于更复杂、单页应用程序,**Flavour** 框架构建于 TeaVM 之上,提供了一个完整的工具包,具有模板、路由、组件和安全等功能——所有这些都使用 100% Java 实现。 Flavour 利用现有的 HTML 和 CSS 技能,确保兼容性并为长期项目提供稳定的 API。 这些技术展示了 Java 开发者构建强大 Web 应用程序的现代途径,超越了 Applet 的限制。

相关文章

原文

Summary

Applets are officially, completely removed from Java 26, coming in March of 2026. This brings to an official end the era of applets, which began in 1996. However, for years it has been possible to build modern, interactive web pages in Java without needing applets or plugins. TeaVM provides fast, performant, and lightweight tooling to transpile Java to run natively in the browser. And for a full front-end toolkit with templates, routing, components, and more, Flavour lets you build your modern single-page app using 100% Java.

Applet History

Applets were first supported in Java 1.0 in 1996. Back then the web was mostly static text, with only the blink or marquee tags (and animated GIFs) to provide dynamic elements without a server round-trip. Applets allowed Java code to provide full interactivity, whether it was a full AWT/Swing GUI, or a Panel/JPanel on which a full Java2D-rendered scene could be built.

Java developers made games, 3D molecule renderings, business applications, and more. While download speeds and processor speeds in the late 90's placed some limits on what could be done, the creativity shown was remarkable. And for developers, the deployment model for their code was very enticing: post your applet on a web page, and anyone on the planet could run it instantly, as long as they had the Java plug-in installed (which, at the time, was very likely).

In the 2000's, politics interfered and browser vendors removed plug-in support, instead preferring their own walled gardens and restricted sandboxes, which often lag behind industry standards for years. This undid years of innovation and broke large parts of the internet that depended on plug-ins.

TeaVM

TeaVM came to the rescue in 2013, giving Java developers a fast, efficient way to use Java code to drive the browser. With short build times, small app sizes, and batteries-included build tooling, TeaVM was a revolution in developing for the web with Java. Apps that previously required numerous round-trips, or duplicating validation and logic in 2 incompatible code bases, could now run natively in the browser while sharing code with the backend.

TeaVM, at its heart, transpiles Java code into JavaScript (or, these days, WASM). However, in order for Java code to be useful for web apps, much more is required, and TeaVM delivers. It includes a minifier, to shrink the generated code and obfuscate the intent, to complicate reverse-engineering. It has a tree-shaker to eliminate unused methods and classes, keeping your app download compact. It packages your code into a single file for easy distribution and inclusion in your HTML page. It also includes wrappers for all popular browser APIs, so you can invoke them from your Java code easily, with full IDE assistance and auto-correct.

TeaVM is revolutionary in its approach and performance. It is a remarkable achievement that opens doors to Java developers. For certain apps, especially games, that primarily render on a canvas, it can be all you need. However, for many web apps, you find you want to build pages out of HTML. You want to build and reuse components. You want binding to reduce boilerplate for populating form elements and reacting to events. You want to communicate with Java services painlessly. For these things, you need Flavour, built on top of TeaVM.

Flavour

The Flavour framework is a batteries-included framework for coding, packaging, and optimizing single-page apps implemented in Java. It supports everything you need in a modern web app, including:
  • Templates
  • Components
  • Routing
  • JSON Handling
  • Resource Embedding
  • Security
Flavour is 100% open source, licensed under the permissive Apache 2.0 license. You never need to worry about license fees or surprises at renewal time.

Flavour is based on HTML templates and CSS for styling, only adding custom tags where needed to implement SPA functionality (conditional markup, variables, etc.). By leveraging HTML and CSS, Flavour ensures long-term compatibility and builds on skills you already have.

Flavour has had a stable API since inception — code written in the earliest days works with only the slightest of changes (addition of a single annotation on POJOs exchanged on the wire). And this stability extends to new releases.

It's easy to get started writing awesome web apps in Flavour:

  • The Flavour Book explains everything you need to build a web app using Flavour, starting with the basics.
  • You can listen to the Flavour Podcast

Last modified on 7 Dec 2025 by AO

Copyright © 2025 Andrew Oliver

联系我们 contact @ memedata.com