JavaCard - methods in Util Class

Hi,
I found that all of array functions in Util class arrayCopyNonAtomic(...), arrayFillNonAtomic(...), arrayCompare(...)
.. invoke equivalent native method. There is no other computation at Java Layer. (if you see from decompile of API code)
So why array function should do this way? I can have an example, for the arrayCompare, we can iterate over all elements and do normal comparison. The same with arrayFillNonAtomic(...). The only function that requires native is related to atomic transaction.
Do you have any reasons for using native beside the speed?
thanks,
Hoang Long

Native code can access the CPU instructions for this directly. Java byte code would be interpreted by the JCVM to eventually call the native instructions. The native code is more efficient and faster. You could do this in Java but it is also trivial in C/assembly.
Cheers,
Shane

Similar Messages

  • Static Methods in Util class

    Dear Gurus,
    I am new to Java and working on a Java Web Application which is already running.
    1)
    I found that the util class methods are static also not Synchoronised.
    I feel this is wrong because if any 2 user accesses the methods concurrently
    then those 2 users will not get expected results.
    2)
    Basically servlets are not thread safe. Then how actually it serves different users who are accessing
    concurrently without any issues.
    Can any one please clarify me the doubts?
    Thanks in advance
    Goudham

    You can declare servlets to be multithreaded. Servlet
    containers are supposed to be able to instanciate a
    different instance of a servlet for every simultanious
    request if you tell it to in the servler descriptor.
    Tomcat does this, and I'm sure that WebLogic, BEA,
    and the Sun on do as well. That way you don't have
    to worry about multi-requests hitting one instance of
    a servlet object. This does add more overhead, but
    sometimes that's ok.To be more precise, you can declare servlets to be non-thread-safe (i.e. SingleThreadModel). This has the affect of preventing concurrent requests from being dispatched to the Servlet instance. Most (in my experience, all) Servlet containers provide the means by which you can set the maximum size of the instance pool for a SingleThreadModel servlet.
    Your best bet is to make your Servlet classes stateless and therefore inherently thread safe. To do this, simply don't define any non-final static or non-static fields and never change the state of those fields). This gives you the greatest scalability. If you must, then have your Servlet implement SingleThreadModel and define an appropriately sized instance pool.
    Of course this won't do anything directly to deal with helper classes and their thread safety issues.
    Chuck

  • The method clearCaches() in class Utility

    to anyone who read this topic,
    I want to clean caches using method clearCaches() in class com.sun.corba.se.impl.util.Utility, but I find there are some discriptions in method definition, it is "Clear the stub/tie caches. Intended for use by
    test code".
    Do this mean it is only for test code usage? very appreciate if anyone could tell me if I can use this method in my code? Does it bring some other impacts if I use it?
    Very thanks,
    Chris
    Software engineer
    Notel

    Hi.
    That's right. according to paramter locator, you will gain interfaces interfaces(Bouquet, Network, ProgramEvent, ProgramEventDescription, ServiceComponent, ServiceDescription, ServiceDetails, SIElement, TransportStream) implements SIRetrievable.
    I will notice you that "SIRequest" returned is for "going" or "canceling". if you get something, it will get parameter "SIRequestor" interface.
    I hope to help you.
    YongHwan

  • Re: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't forget about the regular expression potential

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

  • Re: [iPlanet-JATO] Use Of models in utility classes

    Hi Matt,
    Sounds like some of the stuff we need to migrate has a lot in common with
    Namburi's project.
    I would be very keen to get hold of a copy of the 'tactic' document you
    mention below, as well as the sample code you mention to replace CspDBResult
    stuff with JDBC results.
    Thanks in advance,
    Phil
    ----- Original Message -----
    From: Matthew Stevens <matthew.stevens@E...>
    Sent: Wednesday, August 08, 2001 7:56 AM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has thedetails
    on various tactics of migrating these type of utilities. Essentially, you
    either need to convert these utilities to Models themselves or keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of custom helper method
    as a replacement whicch uses JDBC results instead of CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100253094145066046167121181">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes. These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do the manipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion for these
    utilities we have to do manually.
    My question is Can we access the the models in the post migration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObject intensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]

    Hi Matt,
    Sounds like some of the stuff we need to migrate has a lot in common with
    Namburi's project.
    I would be very keen to get hold of a copy of the 'tactic' document you
    mention below, as well as the sample code you mention to replace CspDBResult
    stuff with JDBC results.
    Thanks in advance,
    Phil
    ----- Original Message -----
    From: Matthew Stevens <matthew.stevens@E...>
    Sent: Wednesday, August 08, 2001 7:56 AM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has thedetails
    on various tactics of migrating these type of utilities. Essentially, you
    either need to convert these utilities to Models themselves or keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of custom helper method
    as a replacement whicch uses JDBC results instead of CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100253094145066046167121181">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes. These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do the manipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion for these
    utilities we have to do manually.
    My question is Can we access the the models in the post migration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObject intensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]

  • How do i call the method in a class using servlet

    i am doing a project which need to use servlet to call a few methods in a class and display those method on the broswer. i tried to write the servlet myself but there are still some errors .. can anyone help:
    The servlet i wrote :
    package qm.minipas;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class test extends HttpServlet {
    Database database;
    /** Initializes the servlet.
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    database = FlatfileDatabase.getInstance();
    /** Destroys the servlet.
    public void destroy() {
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("this is my class wossname"+FlatfileDatabase.getInstance()); // this is calling the toString() method in the instance of myJavaClass
    out.println("this is my method"+FlatfileDatabase.getAll());
    out.println("</body>");
    out.println("</html>");
    out.close();
    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    my methods which i need to call are shown below:
    public Collection getAll() {
    return Collections.unmodifiableCollection(patientRecords);
    public Collection getInpatients() {
    Collection selection=new ArrayList();
    synchronized(patientRecords) {
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(next.isInpatient())
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByAdmissionDate(Date dateOfAdmission) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(dateOfAdmission.equals(next.getDateOfAdmission()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByAdmissionDates(Date from,Date to)
    throws IllegalArgumentException {
    if(to.before(from))
    throw new IllegalArgumentException("End date must not be before start date");
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    Date nextAD=next.getDateOfAdmission();
    if((nextAD.after(from)||nextAD.equals(from))
    &&(nextAD.before(to)||nextAD.equals(to)))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByDischargeDates(Date from,Date to)
    throws IllegalArgumentException {
    if(to.before(from))
    throw new IllegalArgumentException("End date must not be before start date");
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    Date nextAD=next.getDateOfDischarge();
    if(nextAD==null)
    continue;
    if((nextAD.after(from)||nextAD.equals(from))
    &&(nextAD.before(to)||nextAD.equals(to)))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByConsultant(String consultant) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(consultant.equalsIgnoreCase(next.getConsultant()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByDischargeDate(Date dateOfDischarge) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(dateOfDischarge.equals(next.getDateOfDischarge()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getBySurname(String surname) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(surname.equalsIgnoreCase(next.getSurname()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByWard(String ward) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(ward.equalsIgnoreCase(next.getWard()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);

    please provide a detail description of your errors.

  • Calling a method in a class extended from thread

    I'm trying to use two threads of type ThreadTest to call the addNum method in the class below. I found that i couldnt call the addnum method with the instances I created but had to make the addnum method static and then call it with the class name ThreadTest.Is there anyway to get round this? i'm doing this exercise to try and understand synchronisation. Thanks
    import java.lang.Thread;
    import java.util.*;
    class ThreadTest extends Thread implements Runnable{
         private int x;
         private static ArrayList intnumbers = new ArrayList();
         public ThreadTest(int no)
              x=no;
         public void run()
              for (int i=0; i<x; i++)
                   try
                   System.out.println(i);
                   Thread.currentThread().sleep((long)(Math.random() * 1000));
              }catch(InterruptedException e ){e.getMessage();}
         public static void addNum(int n)
              synchronized(intnumbers){
                        intnumbers.add(new Integer(n));
    public static void main(String[] args)
         Thread  testThread = new Thread(new ThreadTest(50));
         Thread  testThreadb = new Thread(new ThreadTest(50));
         testThread.start();
         testThreadb.start();
              ThreadTest.addNum(10);
        //*** this gives an error
        //testThread.addNumber(10);
        //testThreadb.addNumber(10);
    }

    ok here goes again. ;).
    import java.lang.Thread;
    import java.util.*;
    class ThreadTest extends Thread implements Runnable{
         private int x;
         private static ArrayList intnumbers = new ArrayList();
         public ThreadTest(int no)
              x=no;
         public void run()
              for (int i=0; i<x; i++)
                   try
                   System.out.println(i);
                   Thread.currentThread().sleep((long)(Math.random() * 1000));
              }catch(InterruptedException e ){e.getMessage();}
         public static void addNum(int n)
              synchronized(intnumbers){
                        intnumbers.add(new Integer(n));
    public static void main(String[] args)
         Thread  testThread = new ThreadTest(50);
         testThread.start();
         //gives error so how can i create 2 instances of testThread and call addNum with them?
         //testThread.addNum(10);
    //works ok but I want to call addNum with 2 different threads
         ThreadTest.addNum(10);
    }

  • ClassNotFoundException on utility class in JTA Transaction

    When using user defined transactions, I am finding I get odd
              ClassNotFoundExceptions. I've tested this primarily on NT/2000, but did
              also confirm it on Solaris. Can anyone explain it?
              The exception only seems to occur if it becomes necessary to throw an
              exception from the EJB. If I am not inside a user defined transaction,
              there are no problems. (Even if the method is marked as Transacation
              Required). Similarly, if no exception is thrown, there is also no problem
              (even though I use plenty of other utility classes)
              The classes (including the utility class) are all in my deployed jar file
              (which is deployed as part of an ear file).
              The error message is below:
              java.lang.ClassNotFoundException:
              com.iknowledge.inext.exception.STInvalidNameException
              at
              weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.
              java:178)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:195)
              at
              weblogic.j2ee.ApplicationManager.loadFromNetwork(ApplicationManager.java:248
              at
              weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:175)
              at
              weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInputStream.
              java:211)
              at
              weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputStream.re
              adClassDescriptor(ChunkedObjectInputStream.java:290)
              at
              java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:906)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
              at
              java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
              at
              java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2263)
              at
              java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:519)
              at
              java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1412)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
              at
              weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
              putStream.java:107)
              at
              weblogic.transaction.internal.PropagationContext.readExternal(PropagationCon
              text.java:304)
              at
              weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
              putStream.java:97)
              at
              weblogic.common.internal.ChunkedObjectInputStream.readObjectWL(ChunkedObject
              InputStream.java:123)
              at
              weblogic.rjvm.MsgAbbrevInputStream.readTxContext(MsgAbbrevInputStream.java:1
              66)
              at
              weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
              ava:156)
              at
              weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:581)
              at
              weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
              at
              weblogic.socket.NTSocketMuxer.processSockets(NTSocketMuxer.java:638)
              at
              weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              

    You closed your Main class with a bracket, so your getConnection() method isn't in a class
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
        public static void main(String[] args) {
            Connection con = getConnection();
            System.out.println("The connection is: " +con );
    }That is your entire Main class. Anything below it isn't in the class.

  • Can I create a JTA EntityManagerFactory in a utility class in a .jar file?

    I have utility classes in a .jar file inside of a .war file deployed in Glassfish 3.1. One of these utility classes, CredentialsUtil, needs to access a database. I can't inject an EntityManager into CredentialsUtil since it is not an EJB. (For security reasons I don't want to make CredentialsUtil an EJB. I want it to be a POJO.)
    In CredentialsUtil I need an EntityManagerFactory that is connected to a datasource defined in Glassfish. Here is the line from CredentialsUtil.java and from the persistence.xml both of which will be in the util.jar file:
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("Credpu");
    <persistence-unit name="Credpu" transaction-type="JTA">
    I can't use RESOURCE_LOCAL since any changes to the datasource configuration must be done in Glassfish rather than changing persistence.xml.
    (The transaction context is not important in CredentialsUtil. It will be called by a WS-Security handler which may not have a transaction context.)
    Can I put the persistence.xml and the CredentialsUtil class that creates the EntityManagerFactory from it inside of the util.jar file (which will be in a .war), or do I have to move the class and a copy of the persistence.xml file out to the .war file? (I'll have to leave persistence.xml in the .jar file too since there are some @Entity in the .jar file. I don't know why but there are @Entity pojos in the .jar file.)
    I'd like to use the existing persistence.xml, but if I can't is there is a way to create an EntityManagerFactory (or EntityManager) that gets its datasource directly from Glassfish, ignoring persistence.xml?
    Thanks.

    Styles in Pages are saved in the documents (or templates). There is no easy method for adding a style to a built-in template (and it is strongly recommended that you do not tamper with them). You can open a built- in template, add your style and save it as a user template so that your new style will be standard in documents created from that template.

  • Using Async calls in a Util class

    I have a Utility class that I want to put code in that I'm reusing over and over again.  This includes Async.handleEvent calls.  If I call an instance of the Util class from a [Test(async)] method, can I use the Async call in that other event?
    When I tried this in my code, it said that it "Cannot add asynchronous functionality to methods defined by Test,Before or After that are not marked async" but my [Test] is marked as async. And when I was in the same class, I was able to have non-Test methods make Async calls.
    Thanks for the help!
    Mocked up Example (please note these are two separate files):
    // Test.as
    package
        import TimerUtil;
        public class Test
            [Test(async)]
            public function waitForTimer():void
                TimerUtil.newTimer();
    // TimerUtil.as
    package
        import flash.events.TimerEvent;
        import flash.utils.Timer;
        import org.flexunit.async.Async;
        public class TimerUtil
            private static var instance:TimerUtil;
            private var timer:Timer;
            private static const TIME_OUT:int = 1000;
            public static function newTimer() : void
                if (!instance) instance = new TimerUtil();
                instance.timer = new Timer(1000, 5);
                instance.timer.start();
                instance.waitForFifthTick();
            private function waitForFifthTick() : void
                Async.handleEvent(this, instance.timer, TimerEvent.TIMER, handleTimerTick, TIME_OUT);
            private function handleTimerTick ( evt:TimerEvent, eventObject:Object) : void
                if ( timer.currentCount == 5 )
                    // We are at the Fifth click, move on.
                else
                    Async.handleEvent(this, instance.timer, TimerEvent.TIMER, handleTimerTick, TIME_OUT);
    Message was edited by: zyellowman2
    I missed a comma.  And a few "instance"s

    Yes, you can put async calls in utility classes or wherever you want. That isn't the issue here though.
    In your test you call TimerUtil.newTimer()
    That code creates a timer and then returns. Then your test returns. At that moment, FlexUnit sees that your test has finished and that there are no outstanding registered asynchronous events so it declares the test a success. Then, a second later, your other method executes and tries to register an async call. FlexUnit has no idea what test this pertains to, or why this call is being made as it is no longer in the context of the original test, hence the message you are receiving that you can only using Async calls inside of a method marked with a Async... as, in FlexUnit's opion, the method that is executing this code no longer has anything to do with a test with an async param.
    The best way to think about this is a chain that cannot be broken. As soon as a method finishes executing with, FlexUnit will declare it a success unless we are waiting on something else (an async event of some sort) That is what the Async syntax really does, it tells the framework not to declare this method a success just yet, and that there is something else we need to account for to make that decision.
    So, right now, in your newTimer() you don't let the framework know that you will be waiting for an async event. Therefore, when that method and the test method is over, so is the test.
    Mike

  • Issue: Using utility class instance

    Hi,
    I need to use OIM APIs.
    I am using Eclipse IDE and have made the settings accordingly.
    I am able to connect successfully and also able to get the instance of factory class.
    Also then I am able to fetch the instance of utility class, tcUserOperationsIntf.
    But next when I am trying to call any method of this utility class using the instance, I am getting null pointer exception.
    Kindly help.

    public class oimtest {
         public tcUtilityFactory getUtilFacObject()throws Exception
              try
                   ConfigurationClient.ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
                   final Hashtable env = config.getAllSettings();
                   tcUtilityFactory ioUtilityFactory;
                   System.out.println("1");
                   tcSignatureMessage mysign = tcCryptoUtil.sign("xelsysadm", "PrivateKey");
                   System.out.println("2");
                   ioUtilityFactory = new tcUtilityFactory(env,mysign);
                   System.out.println("3");
                   return ioUtilityFactory;
              catch(Exception e)
                   System.out.println("Exception in establishing connection is: "+e);
                   return null;
         public void mymethod()throws IOException, ServletException
    String orgid = "Xellerate Users";
    HashMap uidmap = new HashMap();
    uidmap.put("Organizations.Organization Name",orgid);
    int a=4;
    Long userkey=new Long(a);
         try
    tcUtilityFactory ioUtilityFactory = this.getUtilFacObject();
    System.out.println("4");
         tcUserOperationsIntf userIntf=(tcUserOperationsIntf)ioUtilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
              System.out.println("6");
              String s=userIntf.toString();
              System.out.println("It is"+s);
              userIntf.disableUser(userkey);
    tcResultSet urset=userIntf.findUsers(uidmap);
    System.out.println("7");
    if(!urset.isEmpty())
    int len =urset.getTotalRowCount();
         System.out.println("length:"+ len);
    catch(Exception ex){
         System.out.println("Exception is: "+ex.getMessage());
         System.out.println("Exception is: "+ex);
    I am getting the following output when calling mymethod() from the main class-
    1
    2
    3
    4
    log4j:WARN No appenders could be found for logger (XELLERATE.ACCOUNTMANAGEMENT).
    log4j:WARN Please initialize the log4j system properly.
    6
    It isThor.API.Operations.tcUserOperationsClient@2f4b20
    Exception is: null
    Exception is: java.lang.NullPointerException

  • JavaDocError: Utility classes should not have a public or default construct

    Hello all,
    I am trying to comply with some check style errors that i am getting and i cannot seem to figure out what is going on. I have set all non-data members to private, except for call point public static void main(string[] args) and i am still getting this error. "Utility classes should not have a public or default constructor." I cannot figure out what is going on, any help would be greatly welcomed. My code is posted below.
    public final class Main
         * Constant Data Member: RECTANGLE
         * Purpose: contains the constant string representing a rectangle.
         * @deprecated RECTANGLE Representitive string value for a rectangle.
        public static final String RECTANGLE = "rectangle";
         * Constant Data Member: TRIANGLE
         * Purpose: contains the constant string representing a triangle.
         * @deprecated TRIANGLE Representitive string value for a triangle.
        public static final String TRIANGLE = "triangle";
         * Constant Data Member: REGEX_NUMBER_TEST
         * Purpose: contains the constant for numerical test within regex method.
         * @deprecated REGEX_NUMBER_TEST regex string for digit comparison.
        public static final String REGEX_NUMBER_TEST = "^[0-9]+$";
         * Constant Data Member: MAX_ARGUMENTS_RECTANGLE
         * Purpose: contains the constant for the maximum number of allowed
         *          arguments coming in from the command line.
         * @deprecated MAX_ARGUMENTS_RECTANGLE constant for rectangle argument.
         *                                      limit.
        public static final int MAX_ARGUMENTS_RECTANGLE = 3;
         * Constant Data Member: MAX_ARGUMENTS_TRIANGLE
         * Purpose: contains the constant for the maximum number of allowed
         *          arguments coming in from the command line, in the case of a
         *          triangle object.
         * @deprecated MAX_ARGUMENTS_TRIANGLE constant for triangle argument limit.
        public static final int MAX_ARGUMENTS_TRIANGLE = 2;
         * Method: main
         * Purpose: Is the execution point for the program. It is in charge of
         *          initiating validation and the creation and application of
         *          objects and their related draw methods.
         * @param args input from the user.
        public static void main(final String[] args)
            String objectType = null;
            int width = 0;
            int height = 0;
            if(args.length > MAX_ARGUMENTS_RECTANGLE || args.length <
                MAX_ARGUMENTS_TRIANGLE || (args.length == MAX_ARGUMENTS_TRIANGLE &&
                !isTriangle(args[0])))
                 // fails
                outputErrorMessage();
            else
                if ((isTriangle(args[0]) && args.length > MAX_ARGUMENTS_TRIANGLE) ||
                    (!isTriangle(args[0]) && args.length > MAX_ARGUMENTS_RECTANGLE))
                    // fails becuase triangle should only have one argument
                    outputErrorMessage();
                else
                    // passes and proceed
                    objectType = args[0];
                    if (validNumber(args[1]))
                        width = Integer.parseInt(args[1]);
                        if(width == 0)
                            outputErrorMessage();
                        else
    ....

    Add a private constructor.
    private Main() {  }
    ...This way it will be not possible to create an instance because it is not needed to use its static members or methods.
    ref : [http://www.javapractices.com/topic/TopicAction.do?Id=40]
    Bye.

  • How does the JVM handle private class parameters in a utility class?

    If I have a class that is public and not labeled as static, but it's constructor is private so that it cannot be instantiated, and all of its parameters and methods are both private and static. The methods modify the private parameters. In this case, the code explicitly is avoiding a singleton pattern, so there isn't even a class being instantiated, so this is a true utility class.
    However, the static methods are accessible from multiple objects, and as far as I can tell, the JVM is persisting the parameters in memory beyond the specific thread that called the static method to begin with.
    The question I have is how the JVM handles this? Are these private parameters assigned memory and are indeed persisted independent of thread, since there is no class reference. I am working with byte code injection, and the assumption is that a direct reference to a static parameter is much faster to call than having to go through an object reference. Of course, from a programmer point of view, I much prefer the singleton pattern since I am so used to hang my hat on a class reference.
    Thanks.

    entguru wrote:
    However, the static methods are accessible from multiple objects...Not if the methods are private, as you seemed to indicate ("all of its parameters and methods are both private and static").
    Are these private parameters assigned memory and are indeed persisted independent of thread, since there is no class reference. There is a class reference. It refers to the class, and is obtainable via the class literal; e.g., MyClass.class.
    ~

  • Static memory utilization in a utility class

    I have a servlet calling a utility class, this utility class has a bunch of static methods. One of these static methods is called getStreamCon() returns a http connection to another server(getStreamCon() has few variables whose scope is limited to the metho), I am trying to understand exactly how the memory is utilized and how the code is executed by this utility class when parallel requests hit the servlet,
    Thanks

    samurais wrote:
    I have a servlet calling a utility class, this utility class has a bunch of static methods. One of these static methods is called getStreamCon() returns a http connection to another server(getStreamCon() has few variables whose scope is limited to the metho), I am trying to understand exactly how the memory is utilized and how the code is executed by this utility class when parallel requests hit the servlet,
    What is there to understand?
    The local method creates local instances. Those take memory until they can be collected.
    return httpconnection(url);Presumably you meant "new" in the above.
    So if you have 10 threads there will be 10 instances of HttpConnection as long as each of those threads is using it.

  • Why do we need private static method or member class

    Dear java gurus,
    I have a question about the use of private and static key words together in a method or inner class.
    If we want to hide the method, private is enough. a private static method is sure not intended to be called outside the class. So the only usage I could see is that this private static method is to be called by another static method. For inner class, I see the definition of Entry inner class in java.util.Hashtable, it is static private. I don't know why not just define it as private. Could the static key word do anything better.
    Could anybody help me to clear this.
    Thanks,

    What don't you get? Private does one thing, andstatic does >something completely different.
    If you want to listen to music, installing an airconditioner doesn't help>
    Hi, if the private keyword is the airconditioner, do
    you think you could get music from the static keyword
    (it acts as the CD player) in the following codes:You're making no sense and you're trying to stretch the analogy too far.
    Private does one thing. If you want that thing, use private.
    Static does something completely different and unrelated. If you want that thing, use static.
    If you want both things, use private static.
    What do you not understand? How can you claim that you understand that they are different, and then ask, "Why do we need static if we have private"? That question makes no sense if you actually do understand that they're different.

Maybe you are looking for

  • How can I get iTunes to stop asking me for my password?

    Lately I'm asked to enter my password two or three times every time I open iTunes, and it's getting old. I am an adult and the sole user of this computer so I don't need big brother Apple looking out for me. Just give me something to sign so Apple's

  • Mail crashes each time I open it

    Frustrations. Every time I try to open mail, it says "The Application MAIL quit unexpectedly." I try to relaunch but nothing changes. I tried calling the so-called helpful support and someone from India couldn't understand my serial number and hung u

  • Itunes is showing someone else's library of music in "owner's library".  How can I fix this?

    I have just purchased this laptop and just tried authorizing my itunes account for this mac and syncing it with my iphone.  It didn't sync and loaded someone else's library under "owner's library".  I am not sure what to do about this, I thought mayb

  • Trouble installing fix pack 3

    Hello, I was able to get the service pack onto my computer and the folders are available when I click on the folder with the executable file I continue to click on a number of folders (package, langs, de, setup). When I get there and try to run it I

  • When trying to connect, java.lang.ClassNotFoundException;

    I can't seem to resolve this error: SearchServlet.java [48:1] unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown db.connect(); ^ =========The error is in the following Servlet: SinglesSearch.Database db=new