什么是com.sun包内? [英] What is inside com.sun package?

查看:123
本文介绍了什么是com.sun包内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像javax包含扩展一样,什么是com.sun包应该包含?

Like javax contains the extensions , What is com.sun package supposed to contain ?

推荐答案

它包含 Sun 标准Java(EE)API的Oracle参考实现。其中 Mojarra (Oracle的参考JSF实现)和 Glassfish (Oracle的参考Java EE实现)使用此包。最好不要在代码中直接使用这些类,因为它会使代码紧密耦合到实现中。对 java(x) API进行编码直接使您可以在不更改代码的情况下更改实现(例如,MyFaces而不是Mojarra和JBoss AS而不是Glassfish)。

It contains Sun Oracle reference implementations of the standard Java (EE) APIs. Among others Mojarra (the reference JSF implementation of Oracle) and Glassfish (the reference Java EE implementation of Oracle) use this package. It's preferable to not use those classes directly in your code as it would make your code tight coupled to the implementation. Coding against the java(x) API directly enables you to change the implementation without changing your code (e.g. MyFaces instead of Mojarra and JBoss AS instead of Glassfish).

请注意, com.sun。* 包不应与 sun混淆。* 包是Oracle JRE背后的内部类,你应该绝对不是导入/使用您的代码,因为它会使您的代码紧密耦合到JRE make / version。不使用 sun。* 包使您可以在所有其他JRE实现(OpenJDK,GCJ等)上运行代码。

Please note that the com.sun.* package should not be confused with sun.* package which are the internal classes behind Oracle JRE which you should absolutely not import/use in your code as it would make your code tight coupled to the JRE make/version. Not using sun.* package at all enables you to run your code on all other JRE implementations (OpenJDK, GCJ, etc).

这篇关于什么是com.sun包内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆