We use to import packages in java like
import java.util.*;

import java.lang.*;

import javax.swing.*;

But, why is it javax for swing?

Recommended Answers

All 7 Replies

Swing was not part of the first version of Java - which only had java.awt
So originally swing was a java extension.

The prefix javax is used for a package of Java standard extension.

Hey javax is a advanced package of java...

Swing is in javax package. So we need to import javax.swing.*;

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.

-Taken from http://stackoverflow.com/questions/727844/javax-vs-java-package

well...swing is a advanced version of java so we are using javax..it gives extra features and it will provide look and feel..
you can create many attractive web pages using swing

uh, no. You're wrong on all counts there...

ORIGINALLY the javax packages were eXtensions (or some people say eXperimental) to the language which were distributed separately.
Rather than cause all the code that was already using them to break when they were integrated into the core distribution, the package names were kept.

It's a lesson in careful design of your public interfaces, what not to do when designing a naming system :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.