1. Overview
1.概述
In this short tutorial, we’ll compare the three different Java Editions. We’ll see what functionalities they provide and their typical use cases.
在这个简短的教程中,我们将比较三种不同的Java版本。我们将看到它们提供的功能以及它们的典型用例。
2. Java Standard Edition
2.Java标准版
Let’s start with the Java Standard Edition, or Java SE, for short. This edition provides the core functionalities of the Java language.
让我们从Java标准版开始,或简称为Java SE。该版本提供了Java语言的核心功能。
Java SE provides the essential components for Java applications: Java Virtual Machine, Java Runtime Environment, and Java Development Kit. As of writing this article, the latest version is Java 18.
Java SE为Java应用程序提供了基本的组件。Java虚拟机、Java运行时环境和Java开发工具包。截至撰写本文时,最新的版本是Java 18。
Let’s describe a simple use case for a Java SE application. We can implement the business logic using OOP concepts, make HTTP requests using the java.net package, and connect to a database with JDBC. We can even display a user interface using Swing or AWT.
让我们来描述一个Java SE应用程序的简单用例。我们可以使用OOP 概念实现业务逻辑,使用java.net包进行 HTTP 请求,并使用JDBC连接到数据库。我们甚至可以使用Swing或AWT来显示用户界面。
3. Java Enterprise Edition
3.Java企业版
Java EE is based on the Standard Edition and provides even more APIs. The abbreviation stands for Java Enterprise Edition, but it can be called Jakarta EE. They both refer to the same thing.
Java EE是在标准版的基础上,提供了更多的API。该缩写代表了 Java 企业版,但也可称为 Jakarta EE。它们都是指同一事物。
The new Java EE APIs allow us to create larger, scalable applications.
新的Java EE APIs使我们能够创建更大、可扩展的应用程序。
Generally, Java EE applications are deployed to an application server. Many web-related APIs are provided to facilitate this: WebSocket, JavaServer Pages, JAX-RS, etc. The enterprise features also include APIs related to JSON processing, security, Java Message Service, JavaMail, etc.
一般来说,Java EE应用程序被部署到一个应用服务器上。提供了许多与 Web 相关的 API以促进这一工作。WebSocket、JavaServer Pages、JAX-RS,等等。企业功能还包括与JSON处理、安全、Java Message Service、JavaMail等相关的API。
In a Java EE application, we can use everything from the standard APIs. On top of that, we can use more advanced technologies.
在一个Java EE应用程序中,我们可以使用标准API中的所有内容。在此基础上,我们还可以使用更先进的技术。
Now let’s see a use case for Java EE. For example, we can create servlets to process HTTP requests from users and create dynamic UI using JavaServer Pages. We can produce and consume messages using JMS, send emails and authenticate users to make our application secure. Furthermore, we can use the dependency injection mechanism to make our code more maintainable.
现在让我们来看看Java EE的用例。例如,我们可以创建servlets来处理用户的HTTP请求,并使用JavaServer Pages创建动态UI。我们可以使用JMS生产和消费消息,发送电子邮件和认证用户以使我们的应用程序安全。此外,我们还可以使用依赖注入机制来使我们的代码更易于维护。
4. Java Micro Edition
4.Java微型版
Java Micro Edition or Java ME provides APIs for applications targeting embedded and mobile devices. These can be mobile phones, set-top boxes, sensors, printers, etc.
Java Micro Edition或Java ME为针对嵌入式和移动设备的应用提供API。这些设备可以是移动电话、机顶盒、传感器、打印机等。
Java ME includes some Java SE functionalities while providing new APIs specific to these devices. For example, Bluetooth, location, sensor APIs, etc.
Java ME包括一些Java SE的功能,同时为这些设备提供特定的新API。例如,蓝牙、定位、传感器API等。
Most of the time, these small devices have resource constraints in terms of CPU or memory. We must consider these constraints when using Java ME.
大多数情况下,这些小型设备在CPU或内存方面有资源限制。在使用Java ME时,我们必须考虑这些限制。
Sometimes the target device might not even be available to us to test our code. The SDK can help with this because it provides emulators, application profiling, and monitoring.
有时,目标设备甚至可能无法为我们提供测试代码。SDK可以帮助解决这个问题,因为它提供了仿真器、应用程序剖析和监控。
For instance, a simple Java ME application could read a temperature sensor’s value and send it in an HTTP request along with its location.
例如,一个简单的Java ME应用程序可以读取一个温度传感器的值,并在HTTP请求中连同其位置一起发送。
5. Conclusion
5.结论
In this short article, we got to know what the three Java Editions are, and we compared the functionalities that each of them provides.
在这篇短文中,我们了解了什么是三个Java版本,并比较了它们各自提供的功能。
Java SE can be used for simple applications. It’s the best starting point for learning Java. We can use Java EE to create more complex and robust applications. Finally, we can use Java ME if we would like to target embedded and mobile devices.
Java SE可用于简单的应用程序。它是学习Java的最佳起点。我们可以使用Java EE来创建更复杂和强大的应用程序。最后,如果我们想针对嵌入式和移动设备,我们可以使用Java ME。