javax 与 java 包

发布于 2024-07-16 03:09:06 字数 126 浏览 9 评论 0原文

javax 包背后的基本原理是什么? java 和 javax 分别包含哪些内容?

我知道很多企业包都在 javax 中,但 Swing、新的日期和时间 api (JSR-310) 以及其他 J2SE 包也是如此。

What's the rationale behind the javax package? What goes into java and what into javax?

I know a lot of enterprise-y packages are in javax, but so is Swing, the new date and time api (JSR-310) and other J2SE packages.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

眼泪淡了忧伤 2024-07-23 03:09:06

最初,javax 旨在用于扩展,有时,某些东西会从 javax 提升到 java。

其中一个问题是 Netscape(可能还有 IE)限制了 java 包中的类。

当 Swing 设置为从 javax“毕业”到 java 时,出现了一些小爆炸,因为人们意识到他们必须修改所有导入。 鉴于向后兼容性是 Java 的主要目标之一,他们改变了主意。

在那个时间点,至少对于社区(也许不是 Sun)来说,javax 的全部意义都消失了。 所以现在我们在 javax 中有一些东西可能应该在 java 中......但是除了选择包名称的人之外,我不知道是否有人能弄清楚其基本原理是什么就事论事。

Originally javax was intended to be for extensions, and sometimes things would be promoted out of javax into java.

One issue was Netscape (and probably IE) limiting classes that could be in the java package.

When Swing was set to "graduate" to java from javax there was sort of a mini-blow up because people realized that they would have to modify all of their imports. Given that backwards compatibility is one of the primary goals of Java they changed their mind.

At that point in time, at least for the community (maybe not for Sun) the whole point of javax was lost. So now we have some things in javax that probably should be in java... but aside from the people that chose the package names I don't know if anyone can figure out what the rationale is on a case-by-case basis.

枯寂 2024-07-23 03:09:06

我认为这是一个历史事件 - 如果一个包作为现有 JRE 的补充而引入,它就会以 javax 的形式出现。 如果它首先作为 JRE 的一部分引入(我相信就像 NIO 一样),那么它就会作为 java 引入。 不知道为什么新的日期和时间 API 最终会遵循这个逻辑......除非它也可以作为一个库单独提供以与早期版本一起使用(这将很有用)。 多年后的注释:它(日期和时间 API)最终实际上最终出现在 java 中。

我相信 java 存在限制> package - 我认为类加载器设置为允许从rt.jar或类似的东西加载java.*中的类。 (在 ClassLoader.preDefineClass 中肯定有一个检查。)

编辑:虽然官方解释(建议的搜索 orbfish 在第一页左右没有产生一个)毫无疑问是“核心”与“延期”,我仍然怀疑在许多情况下,任何特定一揽子计划的决定背后也有历史原因。 例如,java.beans 真的是 Java 的“核心”吗?

I think it's a historical thing - if a package is introduced as an addition to an existing JRE, it comes in as javax. If it's first introduced as part of a JRE (like NIO was, I believe) then it comes in as java. Not sure why the new date and time API will end up as javax following this logic though... unless it will also be available separately as a library to work with earlier versions (which would be useful). Note from many years later: it (date and time API) actually ended up being in java after all.

I believe there are restrictions on the java package - I think classloaders are set up to only allow classes within java.* to be loaded from rt.jar or something similar. (There's certainly a check in ClassLoader.preDefineClass.)

EDIT: While an official explanation (the search orbfish suggested didn't yield one in the first page or so) is no doubt about "core" vs "extension", I still suspect that in many cases the decision for any particular package has an historical reason behind it too. Is java.beans really that "core" to Java, for example?

铃予 2024-07-23 03:09:06

java 包是基础javax 包是扩展。

Swing 是一个扩展,因为 AWT 是原始的 UI API。 Swing 随后出现,版本为 1.1。

java packages are base, and javax packages are extensions.

Swing was an extension because AWT was the original UI API. Swing came afterwards, in version 1.1.

枉心 2024-07-23 03:09:06

javax 命名空间通常(这是一个加载的词)用于标准扩展,当前称为 可选包。 标准扩展是非核心 API 的子集; 非核心 API 的另一部分显然称为非标准扩展,占用诸如 com.sun.* 或 com.ibm. 之类的名称空间。 核心 API 占用 java. 命名空间。

Java API 世界中的一切并非都是从核心开始的,这就是为什么扩展通常是从 JSR 请求中诞生的。 他们最终根据“明智的建议”晋升为核心。

对这个命名法的兴趣源于Sun 方面的失礼——扩展本可以提升到核心,即从javax.* 转移到java.*,从而破坏了向后兼容性的承诺。 程序员们声嘶力竭,理智占了上风。 这就是为什么 Swing API 尽管是核心的一部分,但仍然保留在 javax.* 命名空间中。 这也是软件包从扩展升级到核心的方式 - 它们只是作为 JDK 和 JRE 的一部分可供下载。

The javax namespace is usually (that's a loaded word) used for standard extensions, currently known as optional packages. The standard extensions are a subset of the non-core APIs; the other segment of the non-core APIs obviously called the non-standard extensions, occupying the namespaces like com.sun.* or com.ibm.. The core APIs take up the java. namespace.

Not everything in the Java API world starts off in core, which is why extensions are usually born out of JSR requests. They are eventually promoted to core based on 'wise counsel'.

The interest in this nomenclature, came out of a faux pas on Sun's part - extensions could have been promoted to core, i.e. moved from javax.* to java.* breaking the backward compatibility promise. Programmers cried hoarse, and better sense prevailed. This is why, the Swing API although part of the core, continues to remain in the javax.* namespace. And that is also how packages get promoted from extensions to core - they are simply made available for download as part of the JDK and JRE.

伤痕我心 2024-07-23 03:09:06

java.* 包是核心 Java 语言包,这意味着使用 Java 语言的程序员必须使用它们才能有价值地使用 Java 语言。

javax.* 包是可选包,它提供了一种标准的、可扩展的方式,使自定义 API 可用于 Java 平台上运行的所有应用程序。

java.* packages are the core Java language packages, meaning that programmers using the Java language had to use them in order to make any worthwhile use of the java language.

javax.* packages are optional packages, which provides a standard, scalable way to make custom APIs available to all applications running on the Java platform.

╰ゝ天使的微笑 2024-07-23 03:09:06

Javax 过去仅用于扩展。 然而后来sun将它添加到java库中忘记删除x。 开发人员开始使用 javax 编写代码。 但后来,suns 决定将其更改为 java。 开发人员不喜欢这个想法,因为他们的代码会被毁掉……所以 javax 被保留了。

Javax used to be only for extensions. Yet later sun added it to the java libary forgetting to remove the x. Developers started making code with javax. Yet later on in time suns decided to change it to java. Developers didn't like the idea because they're code would be ruined... so javax was kept.

海之角 2024-07-23 03:09:06

javax.swing这样的一些包最初并没有包含在java标准库中。 Sun公司决定将它们视为正式的,并将它们作为标准库或标准扩展纳入早期版本的java中。

按照惯例,所有标准扩展都以 X 开头,而随着时间的推移,它们可以晋升为一流扩展,就像 javax.swing 所发生的情况一样。

Some packages like javax.swing were not included in java standard library at first. Sun company decided to consider them official and included them into the early versions of java as standard libraries or standard extensions.

By convention, all the standard extensions start with an X while they can get promoted to first-class over time like what happened for javax.swing.

泼猴你往哪里跑 2024-07-23 03:09:06

所有 javax 软件包都旨在成为实验性软件包。 当 Swing 足够稳定并准备好转移到 java 包时,那里的代码太多了,他们决定保留它,因为这是为了保持向后兼容性的承诺。 Laura Lemay 和 Rogers Candedhead 撰写的 Sams 社论《Learn Java in 21 days》一书中解释了这一点。

All the javax packages were aimed to be experimental packages. By the time Swing was stable enough and ready to be moved to the java package there was too much code out there that they decided to leave it as it is to keep their commitment with backwards compatibility. This is explained in the book Learn Java in 21 days from the Sams editorial, written by Laura Lemay and Rogers Candedhead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文