When I go to JavaDocs I find some classes in java
package while some are in javax
. Then I came across javax vs java package.
What i get from this link
almost from all answers is that javax
package is just an extension of java library. I mean first Java must had come with core Java libraries I.E. java
package but when some more package got developed they released with javax
. Right?
Some question which immediately comes to my mind as developer. What are implications these of differently named packages for a Java developer. Here are the questions and analysis:-
javax
is just extension of core java. But then again I see totally different packages like org.omg.CORBA
etc. Why this is named javax.omg.CORBA
?javax
, org
, come with standard JDK and JRE download? Do these need to be downloaded separately from JSE 1.6?java.lang
).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.
Package javax.Provides interfaces for tools which can be invoked from a program, for example, compilers. These interfaces and classes are required as part of the Java™ Platform, Standard Edition (Java SE), but there is no requirement to provide any tools implementing them.
The javax prefix is used by the Java programming language for a package of standard Java extensions. These include extensions such as javax. servlet, which deals with running servlets, and javax. jcr, which deals with the Java content library.
Javax is the package name for Java platform library extensions; goodies that are notionally outside the core functionality but are actually part of the core Java platform library.
I think it's fairly arbitrary. As Jon Skeet says in his answer to the question you link to, much of it historical. A good example of this is javax.sql - it contains classes to do with JDBC that were originally part of J2EE, but which were brought into J2SE in 1.4. So now there is a pointless split of classes between java.sql and javax.sql. There's no particular meaning attached to the java/javax split inside the JDK.
Historically, the idea was that java.* packages would be the ones that shipped with the JDK, and the javax.* packages would be the ones that have to be downloaded separately. It still does work this way, to an extent; all java.* packages come with the JDK, and there are many javax.* packages, like for servlets, that have to be downloaded separately.
A monkey wrench was thrown into this scheme when Sun decided to move some javax.* packages, like Swing, into the main JDK. They were actually going to change the package name from javax.swing to java.swing, but when it became clear that this would break backwards compatibility for a huge amount of code, they decided instead to move the packages in, but keep the javax.swing name. So the name is no longer indicative, but is there for historical reasons.
It wouldn't surprise me if the same thing happened to the org.omg and org.w3c packages (they were third-party libraries that got moved into the core JDK and the names couldn't be changed). Regardless, if it's in the JDK API docs, you can use it without downloading anything apart from the main JDK, and the class loader will find it just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With