File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Basic Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Basic Question" Watch "Basic Question" New topic
Author

Basic Question

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
This is a very basic question that. When u say java SomeFile & say in ur program u imported java.awt.*; or any other packages. Now the question is are all the classes from the imported package loaded into the memory or they are just registered or any thing else.
Any comments.
Bye,
Jiger
Manoj Prithiani
Greenhorn

Joined: Nov 03, 2000
Posts: 13
Hi Jigar,
All the classes are loaded in memory and their syntaxes checked at compile time. But not the classes within Subpackages
naveen sahu
Ranch Hand

Joined: Nov 15, 2000
Posts: 48
i think all the classes not loaded
Gregg Dale
Greenhorn

Joined: Nov 16, 2000
Posts: 7
Actually, the statement
import java.awt.*
is only shorthand. It only tells the compiler that for any instance of a Class MyClass that I call in my code, it may have a fully qualified reference of java.awt.MyClass. It doesn't load any Classes that aren't called for in your code, it merely describes the package(s) in which to look for referenced Classes.
The compiler searches the current package and all "imported" packages to reconcile all Class references in your Code.
[At Java University at Comdex last year the instructor expressed his opinion that "import" had been a poor choice of syntax for that feature.]
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
'Jiger_ptl',
Welcome to JavaRanch.
May I remind you PROPER NAMES ARE NOW REQUIRED!!
Please Read the JavaRanch naming policy for more details.
Javaranch appreciates your cooperation to comply with the official naming policy.
Ajith

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
No, none of those classes are loaded into memory. It's basically just telling the compiler that you would like to reference those classes by their short name. The compiler takes care of the mapping, verification, etc.
Bosun
SCJP2


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Friends,
If that is the case then why do saying
java -verbose MyFile
displays the name of all the Classes in the Packages I have imported.
Like
[Loaded sun.java2d.loops.TextRendering from C:\Program Files\JavaSoft\JRE\1.2\li
b\rt.jar]
[Loaded sun.java2d.loops.DrawString from C:\Program Files\JavaSoft\JRE\1.2\lib\r
t.jar]
[Loaded sun.java2d.loops.DrawChars from C:\Program Files\JavaSoft\JRE\1.2\lib\rt
.jar]
[Loaded sun.java2d.loops.DrawBytes from C:\Program Files\JavaSoft\JRE\1.2\lib\rt
.jar]
[Loaded sun.java2d.loops.DrawGlyphVector from C:\Program Files\JavaSoft\JRE\1.2\
lib\rt.jar]
[Loaded sun.java2d.loops.IndexGrayAccelerators from C:\Program Files\JavaSoft\JR
E\1.2\lib\rt.jar]
[Loaded sun.java2d.pipe.AlphaColorPipe from C:\Program Files\JavaSoft\JRE\1.2\li
b\rt.jar]
[Loaded java.awt.Dimension from C:\Program Files\JavaSoft\JRE\1.2\lib\rt.jar]
[Loaded java.awt.geom.Dimension2D from C:\Program Files\JavaSoft\JRE\1.2\lib\rt.
jar]
[Loaded sun.awt.image.BufferedImageGraphics2D from C:\Program Files\JavaSoft\JRE
\1.2\lib\rt.jar]
[Loaded sun.java2d.pipe.ShapeToPolyConverter from C:\Program Files\JavaSoft\JRE\
1.2\lib\rt.jar]
[Loaded sun.java2d.pipe.LineStylePipe from C:\Program Files\JavaSoft\JRE\1.2\lib
\rt.jar]
and many others....
Any answer.
Bye,
Jiger
rchopp
Greenhorn

Joined: Nov 17, 2000
Posts: 6
Hi,
As my understanding goes..
Those classes that are listed in the verbose mode are the ones used by the JVM internally. Remember that JAVA is a JIT (Just In Time) Compiler. It loads the classes needed when necessary.
Thanks,
Ravi.


Thanks,<BR>Ravi Kiran Choppalli
subbu smile
Greenhorn

Joined: Nov 17, 2000
Posts: 2

I think, by writing the full path of a class which we required to import in our programme reduce the compile time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Basic Question