Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between java & javax in import statement  RSS feed

 
satya sahu
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, what is the difference between the import java and import javax?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"import" tells the Java compiler that it should look in a particular package for the Java classes named in a source file; i.e., if you write
Vector v = new Vector();
Then you must include a line like
import java.util.*;
or
import java.util.Vector;
to tell the compiler which "Vector" you mean.
That said, there's no difference at all between "import java..." and "import javax..." it's just that some of the Java API packages are named java.something, and others are named javax.something. Originally, the "javax" names were supposed to represent "extensions" to the Java core, but in a controversial decision, Swing was released in a javax package, and since then the conceptual difference has been minimal.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!