What is import statement for ?

Hi all,
Sorry for asking a silly question. Since it is a new to java forum I am asking this.
What is happening when an import statement is triggered at compile time and at runtime.
What is the difference/advantages/disadvantages between importing an entire package and importing required classes only.
Is there any size limit on the generated class file.
rgds
Antony Paul

looks like we are both beguinners
i just received a newsletter from sun and in it has this
MONITORING CLASS LOADING AND GARBAGE COLLECTION
Have you ever wondered what classes are loaded when you launch an application or from where the classes are loaded? Have you ever wondered when garbage collection runs or how long it takes? The java command line tool offers several different command line options that you can use to get answers to those questions.
You might already be familiar with a number of command line options available with the java command line tool, such as -cp, -Xms, and -Xmx. The -cp option is used for specifying the classpath. The -Xms and -Xmx options are used to specify the heap size. For example, instead of setting the CLASSPATH environment variable, you can use the -cp option to tell the system to look in a specific directory for necessary class files:
java -cp ExampleDir MyExample
Here, the system will look in the ExampleDir subdirectory for the MyExample.class file and anything else needed besides the system classes. The ExampleDir in the command line tells the system to look only in the ExampleDir directory (assume that it's the parent directory). If MyExample.class is located in the current working directory, the system would not find it.
Two less frequently used command line features report on class loading and garbage collection. The -verbose:class option reports when a class is loaded into the Java virtual machine and from where it came. For instance, if you use the -verbose:class option when loading the SwingSet2 demo that comes with the J2SE 1.4.2 SDK, you get a report on the many different classes that are loaded as part of the demo, such the following two:
java -verbose:class -jar
C:\j2sdk1.4.2\demo\jfc\SwingSet2\SwingSet2.jar
[Loaded FilePreviewer]
[Loaded javax.swing.plaf.TableUI from
     C:\j2sdk1.4.2\jre\lib\rt.jar]
The first line indicates that the class came from the main JAR for the demo (assuming it was started with java -jar SwingSet2.jar). The second line indicates that the TableUI class was loaded from the rt.jar file that comes with the runtime located in the c:\j2sdk1.4.2\jre directory. (From there, the rt.jar file is located in the lib subdirectory.) Different implementations of the Java platform can have different formats here. The only requirement is that -verbose:class displays messages as classes get loaded and unloaded.
Let's see when classes are loaded, and how many classes are needed for the following simple program:
public class Sample {
public static void main(String args[]) {
System.out.println("Hello, World");
Compile the Sample class. Then run it with the -verbose:class option enabled:
java -verbose:class Sample
When you run the command, you'll see that this simple program requires the opening of five jar files (such as rt.jar) and the loading of almost 250 classes.
To see an example of a class unloading message, try the -verbose:class command line option with the RunItReload class shown in the August 19, 2003 Tech Tip titled Unloading and Reloading Classes.
The -verbose:gc option reports on each garbage collection event. This includes the time for garbage collection to run, and the before and after heap sizes. This is demonstrated in the following lines:
[GC 27872K->26296K(42216K), 0.0069590 secs]
[GC 28973K->26455K(42216K), 0.0036812 secs]
[GC 29134K->26474K(42216K), 0.0016388 secs]
[GC 29117K->26487K(42216K), 0.0008859 secs]
[GC 29134K->26498K(42216K), 0.0009197 secs]
[GC 29180K->26479K(42216K), 0.0008711 secs]
[GC 29149K->26484K(42216K), 0.0008716 secs]
Like the output for -verbose:class, there is no requirement for output format, and it is subject to change without notice. The "GC" at the beginning indicates what kind of collection occurred. The number before the "->" is the heap occupancy before the collection. The number after the "->" is the heap occupancy after the collection. The number in parentheses is the currently allocated size of the heap. The seconds are the duration of the collection.
This information can be useful in debugging. For example, it could help you determine if garbage collection happened at a critical point in time, and might have caused a program to crash. This sometimes happens when mixing Java and C/C++ code with JNI, especially when there is an underlying bug on the C/C++ code side.
If you're ever curious about why it takes so long for an application to start, or if garbage collection in the middle of an operation appears to cause a problem, be sure to try out these command line options.
hope it helps

Similar Messages

  • Import statement for DateCalculator

    Hi
    What import statement should I add in my wed dynpro implementation for DateCalculator, I already added
    import java.util.Date;

    Hi,
    If you want to perform some opperation with date in webdynpro,we have to import the some more along with above mentioned.like
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    Thanks,
    Murthy.

  • Why the need of "import" statements for Java base code?

    If for documentation purposes, a compiler option to produce an "import list" would have been sufficient.

    import statements act as really simple namespaces.
    Instead of the programer having to specify:
    java.io.File f = new java.io.File("c:\\");
    the code can have a 'namespace' added to do the following:
    import java.io.file;
    File f = new File("c:\\);
    it's a way of getting around similiarly named classes, but still have the ability to drop the 'java.io.' part.

  • What are  import parameters for bapi

    please tell me what are the minimum  fields i  has to pass for bapi
    " BAPI_SALESDOCUMENT_CHANGE ".
    if  possible  give me with example
    Moderator message: please (re)search yourself first.
    Edited by: Thomas Zloch on Dec 8, 2010 9:07 AM

    Hello,
    It will all depend on what you need to change in the sales order.
    For example, if you want to change something in the header only, then you need to pass ORDER_HEADER_IN and ORDER_HEADER_INX.
    Similarly, if you want to change something only in the sales items then you need to pass the value in SALESDOCUMENT, ITEM_IN and ITEM_INX.
    So, it will all depend on your need.
    But, always pass a table in RETURN so that you get to know whether BAPI has executed successfully or there is some error in the processing.
    Hope it helps.
    Regards,
    Himanshu

  • Problem with import statement for user created classe

    I recently downloaded J2sdk1.4.0_03 before that I had jdk1.3 and never had this problem.All the files other than named package I import for my
    application does not compile.But when I commented that out it work just fine.
    any help is appreciated

    thanks
    It makes sense not to import non-packaged class.
    My other problem is with JDBC ODBC.I have a Dell system with Windows XP.
    I registered my User Data Source to ODBC with MS Text driver(.txt , csv).When the code reaches at the .executeUpdate(CREAT TABLE CUSTOMERS)
    it throws an exception
    sQLException 3:java.sql.SQLException: [Microsoft][ODBC Text Driver] Cannot modify the design of table 'CUSTOMERS'. It is in a read-only database.
    Do I really need to change the attribues or some thing else.
    How can I chane the attributes of the database.Never had problem with windows 98.

  • Automatic import statements for jsp's?

    Is there a feature in Workshop 9.x's jsp editor that will automatically resolve (or prompt to resolve) classes in use which have not yet been imported into the page? A blue box appeared in 8.x and you could select the class to import, but I'm not finding it in 9.x.

    Greg Foreman wrote:
    Is there a feature in Workshop 9.x's jsp editor that will automatically resolve (or prompt to resolve) classes in use which have not yet been imported into the page? A blue box appeared in 8.x and you could select the class to import, but I'm not finding it in 9.x.Unfortunately no, this is a feature missing from the underlying WTP that
    Workshop is based on for JSP editing.
    Gerald

  • What are import settings for downloaded purchases?

    import settings on itunes isnt the same settings for purchased downloads?

    Import settings do not apply to purchases.  When you purchase a download, it comes in the format provided by the store. 
    Some common formats are AAC/256 (iTunes Store), MP3/256 (Amazon MP3), and MP3/320 (Google Play).

  • Import statement .. what does it do ??

    Hi All,
    What is IMPORT statement doing ??
    IMPORT order_items_in to w_order_items_in from MEMORY ID
    'FREEGOODSTERMS'.
    can you kindly explain what this statement is doing ?
    I was by my friend that this is used to pass order_items from one session to this sesssion, but when I searched for FREEGOODSTERMS, I could find export after this statment. I was wondering how can import me first and then export.
    Please let me know.
    Thanks
    venkat.

    Hello Venkat,
    Sorry for late reply..
    Please see the program which other program submitting somewhere.
    if they are using multiple purpose then export and import statement may possible in one include.
    Best way just use where used list for that include and other programs searching like export and submit..
    For better understanding about export and import then see the below sample programs.
    Create one program and paste below code :
    REPORT  ZTEST_AMEM1.
    tables : lfa1.
    data : begin of i_lfa1 occurs 0 ,
           lifnr like lfa1-lifnr,
           name1 like lfa1-name1,
           land1 like lfa1-land1,
           end of i_lfa1.
    start-of-selection.
    select lifnr
           name1
           land1 from lfa1
           into table i_lfa1 up to 100 rows.
    Export
    export i_lfa1 to memory id 'SAP'.
    submit ztest_amem2 and return.
    write:/ 'hello'.
    Now create one more program  and paste below code :
    REPORT  ZTEST_AMEM2.
    data : begin of j_lfa1 occurs 0,
           lifnr like lfa1-lifnr,
           name1 like lfa1-name1,
           land1 like lfa1-land1,
           end of j_lfa1.
    start-of-selection.
    import i_lfa1 to j_lfa1 from memory id 'SAP'.
    loop at j_lfa1.
    write:/ j_lfa1-lifnr,j_lfa1-name1,j_lfa1-land1.
    endloop.
    Thanks
    Seshu

  • Import statement *not* required?

    Can someone explain this to me? I was following along a
    simple AS3 example (in the design video workshop) where a "Power
    Button" has some MouseEven CLICK event handling applied to it with
    a trace statement as the resulting handled function. Really simple
    basic example. The import statement is import
    flash.events.MouseEvent.
    How come removing the import statement does not produce an
    error?
    Reference:
    import flash.events.MouseEvent;
    myButton.addEventListener(MouseEvent.CLICK, myButtonClicked);
    function myButtonClicked(event:MouseEvent):void {
    trace('do Something');
    }

    midimidi,
    > So to be clear...if the AS is on the main timeline,
    import statements
    > are not needed, and if the AS is external and imported,
    import
    > statements are needed.
    That's a general rule of thumb, but not 100% applicable.
    > Are there any other exceptions to that, or does that go
    for all AS3
    > classes?
    There are exceptions, and the easiest way to find them is to
    leave out
    your import statements and plug away ... sooner or later,
    you'll get a
    compiler error, and then you'll know. :)
    >> It did strike me *** odd though, an imported .as
    file uses the same
    >> publish settings as code on the timeline. So why
    treat them differently?
    FLA files have publish settings, but AS files don't. They're
    just text
    files. I hear what you're saying ... they end up getting
    compiled along
    with / into the some FLA anyway -- and that FLA does have
    classpaths
    listed -- but those same AS files might be compiled in Flex
    Builder 2 or
    some 3rd party compiler. It would probably make good sense to
    require the
    import statement for inline FLA code, but not everyone is a
    hardcore
    programmer, and Adobe knows it. Nothing is *hurt* by using
    import in FLAs,
    but for folks who just want to do light programming, the
    convenience of not
    having to use it is nice.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • FB Beta 2 removing import statements

    I have a project that was started in FB Beta 1 (everything was working great) and updated to FB Beta 2 SDK 4.0.0.10988.  I have a frequent but inconsistent problem in which while working in a module I'll have import statements in my script removed.  The last instance two import statements for user created MXML components were removed, and the code I was modifying didn't have anything to do with these components.  Previously I had import statements for ConversionType and TextConverter removed, this time I put the import statements in right before writing code to use them.
    I still have problems with Flash Builder Beta 2 output folder issues this is a previous post that was unanswered.
    If it helps: using MAC OSX and FB Beta 2 standalone.

    The issue with comments being removed when organize imports is run is a known issue captured by a small set of bugs:
    https://bugs.adobe.com/jira/browse/FB-18479 Comments do not remain with currect import statements when performing 'organize imports'
    https://bugs.adobe.com/jira/browse/FB-11396 Any data in between imports are deleted when doing an "organize imports" operation
    https://bugs.adobe.com/jira/browse/FB-17160 Import inserted into wrong location when existing import is followed by a single line comment
    Essentially, what it boils down to, we follow the same behavior as the JDT with one glaring exception: Turn off organizing imports when auto importing from code hints:
    https://bugs.adobe.com/jira/browse/FB-23179 Change code hints auto import behavior so that imports are inserted in order, but unused imports should not be removed
    With the FB-23179 fix, your imports will only be removed when you explicitly organize imports. I hope this info helps.
    Jason San Jose
    Quality Engineer, Flash Builder

  • Javac(1.4.2) gives error in import statement

    Hi All,
    I am facing a surprising problem. I have 2 java class files. I write the import statement for second one in the first one. There is no package & these are in the same directory. I have compiled the second one. But when I try to compile the First one. Javac throws error at import statement like below :
    D:\Clubs\oct\6>javac -d . ManojTest.java
    ManojTest.java:1: '.' expected
    import SessionBean;
    ^
    1 error
    My Java Files are as below :
    import SessionBean;
    public class ManojTest
         public static void main(String args[])
    //ManojTest.java
    public class SessionBean
         public static void main(String args[])
    //SessionBean.java
    I have compiled SessionBean.java successfully but when I try to compile ManojTest.java I get error mentioned above.
    However this probelm comes when I use j2se 1.4.2.. but works in j2se 1.3.1..
    Another way could be I use package structure.
    But I can't do any of these, as I have to port my big project to j2se1.4.2.. from j2se1.3.1.. (Live project is running on Tomcat).
    Problems is similar in Unix & Windows both.
    Is this javac compiler issue or there is some setting which I can make.
    I have already included . (dot) in PATH & CLASSPATH environment varibales.
    Please help me out if there is any way around this, as i am stuck up in between
    thank you
    Manoj :confused:

    Use a package and then add that package in your classpathOr don't use a package, leave the file in the default (noname) package, and don't use the import statement. Java will find it in the default package without the import.
    Explicit import statements from the default package are no longer allowed

  • How to organize the import statements in FXML Files?

    Hello,
    I'm a user of NetBeans IDE and it can organize the import statements in *.java files. Now, I'm using JavaFX and editing the *.fxml files as well. I want to know how to organize the import statements in *.fxml files?
    Thanks a lot.

    You should use Scene Builder, it will make all these import statements for you.
    Moreover, it will greatly simplify the writing of your FXML files, since you only have to Drag&Drop JavaFX objects on the scene. Then, it automatically generates FXML files.

  • Variable within an import statement

    I'm wanting to have a variable in an import statement for different versions of a class
    example - import someclass.VERSION.*;
    but I want VERSION to be a variable that I can modify for every project that uses the class I'm importing from. I have not found any examples that have done this thus far.

    The point of my suggestion was that it would make it unnecessary to change anything at all for compiling different versions.
    make 3
    Making version 3.0 <<<See how easy that can be? Reading the version of the class to load from an external class file and dynamically loading it is tantamount to a Rube Goldberg machine. Also, you still have to change a file, your properties file. If your project grows to any significant size, this approach will cause you serious headaches.

  • Auto-organization of import statements broken

    Anyone else having this problem?
    it happens pretty regularly, when I use auto-complete on a new object type, then flexbuilder goes and totally screws up all my imports, causing me to have to go through and ctrl-space (alt+"/" ) each one.
    Also, it seems to never put in the correct import statement for an MXML component that I refer to in my AS block. I finally just used the fully qualified name because I was sick of FlashBuilder removint the import after I added it 5 times.

    Known bug http://bugs.adobe.com/jira/browse/FB-23179 or one of the related bugs.
    Jason San Jose
    Quality Engineer, Flash Builder

  • What camera to buy for taking close pictures of coins in mint state condition?​???

    hi
    what camera to buy for taking close pictures of coins in mint state condition????uncirculated coins ??

    BetterWay wrote:
    The camera is not so much of an issue here as making sure that you get the right glass(lens) .
    Both Nikon and Canon have specialty lenses to allow Macro (1:1 or lifesize or greater magnification) images to be made.
    I would also recommend that you get a good tripod and focusing rails to mount your camera on as most macro photography is best done using manual focus and moving the camera.  This is due to the fact that macro lenses have a very shallow depth of field.
    If you don't want to go to this extreme, then at least get a small sturdy tripod and always use a remote shutter release.
    All of this is related to DSLR's.
    If you want to go the PnS route, then look for one that emphasizes its macro capability and again, use a tripod.  Again, the lens is the most important item here.
    Actually, no - lens is not the most important - coins are highly reflective and as a result VERY difficult to light properly - the lighting equipment is going to be the most important.
    Lens will be second most important - you can probably do fine for coin photography with one of the common pseudo-macro lenses that only do 1:2 and not 1:1.  However a true 1:1 macro lens will give you the most flexibility.
    Since the lighting equipment is the most important, the key here is going to be that the camera has support for an external flash.  This is guaranteed for an SLR but rare in P&S cameras.
    *disclaimer* I am not now, nor have I ever been, an employee of Best Buy, Geek Squad, nor of any of their affiliate, parent, or subsidiary companies.

Maybe you are looking for