是否有 Java EE JDK

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10438127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 01:03:07  来源:igfitidea点击:

Is there a Java EE JDK

jakarta-eejava

提问by Amir Abiri

I know this has been asked a million times and I did do my homework, but the one last thing I don't fully understand is, is there a "Java EEJDK" ?

我知道这已经被问了一百万次并且我确实做了功课,但我不完全理解的最后一件事是,是否有“Java EEJDK”?

When I download the SDK, it tries to install lots of crap I don't want. So I did some reading and realized that actually the Java SDK is a set of tools technically unrelated to the JDK. So what I am looking for is a clean simple standalone download of the JDK only.

当我下载 SDK 时,它会尝试安装很多我不想要的垃圾。所以我做了一些阅读并意识到实际上 Java SDK 是一组技术上与 JDK 无关的工具。所以我正在寻找的是一个干净简单的 JDK 独立下载。

We know that "Java SE JDK" has always been availablefrom Sun's (now Oracle) website. However, I am developing a web application and interested in someof the Java EE features: javax.servlet, javax.validation, javax.persistence and javax.transaction. So in effect what I'm really looking for is a "Java EE JDK".

我们知道“Java SE JDK”一直可以从 Sun(现在是 Oracle)的网站上获得。但是,我正在开发一个 Web 应用程序并且对一些Java EE 功能感兴趣:javax.servlet、javax.validation、javax.persistence 和 javax.transaction。所以实际上我真正在寻找的是“Java EE JDK”。

I'm using a typical Maven / Tomcat / Spring / Hibernate setup and in the past I've always added API-only dependencies in provided scope in Maven to my project for these parts of the Java EE specification, i.e:

我正在使用典型的 Maven / Tomcat / Spring / Hibernate 设置,过去我总是在 Maven 中提供的范围内将仅 API 依赖项添加到我的项目中,用于 Java EE 规范的这些部分,即:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
</dependency>

So if I do this for all the Java EE APIs that my project requires, then I am actually using Java SE JDK with some additional manually-declared Java EE components. Furthermore when I direct my IDE to use the JDK that came with the Java EE SDK installation, these additional namespaces aren't available.

因此,如果我对项目所需的所有 Java EE API 都这样做,那么我实际上是在使用 Java SE JDK 和一些额外的手动声明的 Java EE 组件。此外,当我指示我的 IDE 使用 Java EE SDK 安装附带的 JDK 时,这些额外的命名空间不可用。

In other words, for all intents and purposes it would appear that the JDK that comes with the Java EE SDK download is equivalent to the JDK that I get when I install the "Java SE JDK"... If this is correct then there is no need for me to install the Java EE SDK and I can simply use the Java (SE) JDK declaring any Java EE components that I need as *-api/provided dependencies the way I described above.

换句话说,就所有意图和目的而言,Java EE SDK 下载附带的 JDK 似乎等同于我在安装“Java SE JDK”时获得的 JDK……如果这是正确的,那么有我不需要安装 Java EE SDK,我可以简单地使用 Java (SE) JDK,将我需要的任何 Java EE 组件声明为 *-api/provided 依赖项,就像我上面描述的那样。

So my questions is: is what I describe above the right way to go, or is there such a thing as a "Java EE JDK"? i.e a JDK that comes with the unimplemented interfaces of things like javax.servlet and javax.resources and so on? And if such a beast exists, where would I download it from?

所以我的问题是:我上面描述的方法是正确的,还是有“Java EE JDK”这样的东西?即带有诸如 javax.servlet 和 javax.resources 之类的未实现接口的 JDK?如果存在这样的野兽,我从哪里下载?

回答by monkHyman

What you're asking is "can I get all the EE components" as a single download without GlassFish, NetBeans, etc.

您要问的是“我可以在没有 GlassFish、NetBeans 等的情况下一次性下载所有 EE 组件吗”。

Well it's helpful to know exactly what Java EE really is. It's a set of specifications of sometimes related / sometimes unrelated "Enterprise" level components (whatever Enterprise means :)). For example, the servlet-api spec (as indicated by a previous answer) is part of the Java EE spec. So is the JTA (transaction API), JPA, Java Mail, and so on.

确切地知道 Java EE 是什么会很有帮助。它是一组有时相关/有时不相关的“企业”级组件的规范(无论企业意味着什么:))。例如,servlet-api 规范(如上一个答案所示)是 Java EE 规范的一部分。JTA(事务 API)、JPA、Java Mail 等也是如此。

There are two types of EE component. 1. Those which are shipped as interfaces only and the application-server or a third party implements them. Examples are JTA, JPA, Servlet-API. 2. Those which are shipped as full reference implementations. Examples are Java-Mail. I can't think of others off top of my head but there will be some.

EE 组件有两种类型。1. 仅作为接口提供并且应用服务器或第三方实现它们的那些。例如 JTA、JPA、Servlet-API。2. 作为完整参考实现提供的那些。示例是 Java 邮件。我无法想到其他人,但会有一些。

Now a full application server, such as glassfish, ships with the set of implementations so lots of times people see them inside Glassfish, Websphere etc and think that they need that to use them. A container such as Tomcat is not an application server, it is a servlet-container and thus only implements a subset of the full Java EE stack (the parts that are required for servlets only).

现在一个完整的应用程序服务器,比如 glassfish,附带了一组实现,所以很多时候人们在 Glassfish、Websphere 等中看到它们并认为他们需要使用它们。像 Tomcat 这样的容器不是应用服务器,它是一个 servlet 容器,因此只实现了完整 Java EE 堆栈的一个子集(仅 servlet 需要的部分)。

In order to get the full set of Java EE interfaces/implementations you would need to add the separate interfaces or implementations to your build. In that case you just "have to know" where to find them, and that comes by experience. People tend to know that JPA is added as part of the Hibernate dependencies for example.

为了获得完整的 Java EE 接口/实现,您需要将单独的接口或实现添加到您的构建中。在那种情况下,您只需要“知道”在哪里可以找到它们,而这取决于经验。例如,人们往往知道 JPA 是作为 Hibernate 依赖项的一部分添加的。

回答by Miguel Reyes

When it comes to downloading the JDK, there is only one JDK, whether you get it from the Java SE downloads or from the Java EE downloads.

在下载 JDK 时,只有一个 JDK,无论您是从 Java SE 下载还是从 Java EE 下载获取。

The difference is that when you download it from the Java EE downloads, it is packed in in a SDK. The SDK comes with Glassfish, Code Samples, API Documentation, Tutorials. I don't really need these so I prefer downloading from the Java SE downloads.

不同之处在于,当您从 Java EE 下载中下载它时,它被打包在一个 SDK 中。SDK 附带 Glassfish、代码示例、API 文档和教程。我真的不需要这些,所以我更喜欢从 Java SE 下载中下载。

In a Maven JavaEE project you would specify your dependencies to the Java EE libraries. In the case of jboss AS7, you use the jboss-spec dependencies that will let you do imports for all the Java EE classes. It is up the Application Server to provide the classes that implement the Java EE APIs:

在 Maven JavaEE 项目中,您将指定对 Java EE 库的依赖项。在 jboss AS7 的情况下,您使用 jboss-spec 依赖项,它将允许您为所有 Java EE 类进行导入。应用服务器负责提供实现 Java EE API 的类:

<dependency>
   <groupId>org.jboss.spec</groupId>
   <artifactId>jboss-javaee-6.0</artifactId>
   <version>3.0.2.Final-redhat-3</version>
   <type>pom</type>
   <scope>import</scope>
</dependency>

If you want to see the javaEE artifacts imported by this pom, take a look at: http://maven.repository.redhat.com/techpreview/eap6/6.1.0/maven-repository/org/jboss/spec/jboss-javaee-6.0/3.0.2.Final-redhat-3/jboss-javaee-6.0-3.0.2.Final-redhat-3.pom

如果你想看到这个 pom 导入的 javaEE 工件,看看:http://maven.repository.redhat.com/techpreview/eap6/6.1.0/maven-repository/org/jboss/spec/jboss- javaee-6.0/3.0.2.Final-redhat-3/jboss-javaee-6.0-3.0.2.Final-redhat-3.pom

回答by Puce

Generally, you're more or less correct.

一般来说,你或多或少是正确的。

The application servers usually ship the Java EE API as well as the implementation of the Java EE API. So in case you want to use the same version as your application server then use:

应用服务器通常会提供 Java EE API 以及 Java EE API 的实现。因此,如果您想使用与应用程序服务器相同的版本,请使用:

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>2.5</version><!-- or whatever version your application server provides -->
   <scope>provided</scope>
</dependency>

If you want to use a newer version you should omit the provided scope.

如果要使用较新版本,则应省略提供的范围。

If you want to use a newer or a different implementation (e.g. EclipseLink instead of Hibernate) you have to add a dependency for the implementation as well. Otherwise you can omit it.

如果您想使用更新或不同的实现(例如 EclipseLink 而不是 Hibernate),您还必须为实现添加依赖项。否则你可以省略它。