Can  object(instance TreeMap) be inserted in a File by objectoutputstream??

Can a object containing TreeMap instance be inserted in a File by objectoutputstream??
class pfore{
static class TextFile
          String category;
          String filename;
                TreeMap filewords;
                TextFile( )
                {category=filename=null;
                 filewords=new TreeMap();
                TextFile(String category,String filename,TreeMap filewords)
          this.category=category;
          this.filename=filename;
               // this.filewords=new TreeMap();
                this.filewords=new TreeMap(filewords);
public static void main (String args[]){
//creating an object of TextFile by reading a text file and also initializing it
TextFile ob=new TextFile("dd","ff",kp);
//kp is a created TreeMap object
*__try{    FileOutputStream fos= new FileOutputStream("serrial.txt");__*
           *__ObjectOutputStream oos=new ObjectOutputStream(fos);__*
            *__oos.writeObject(ob);__*               
             *__oos.flush();__*
             *__oos.close();__*
                  *__catch(IOException e) {__*
       *__System.out.println("exception while opening the filestream"+e);__*
       *__e.printStackTrace();__*
       *__System.exit(0);__*
}//end main
}//end class
Please see the underlined part because other parts are completely ok.
it's giving exceptions like
at.java.io.objecstreamclass invokewriteObject
at.java.io.objectoutputstream.writeserialData
at.java.io.objectoutputstream.writeOrdinaryObject.etc..etc

suppose a class is a textfile in java..containing a TreeMap instance ,and two string variables as instance..
class textfile implements Serializable
String foo;
String foo1;
TreeMap t;
textfile t=new textfile( );now how to write object t in file??
with objectoutputstream i have tried it..bt it is throwing exceptions..
the details i have posted in my previous Question(see above-the code)
please give in details how to do this??

Similar Messages

  • How can i have a refrence of a java class object instance in my c++ project

    Hi!
    How can i have a refrence of a java class object instance in my c++ project. Is there a way?

    hahaxia wrote:
    The second question is the big one. The first question is half of the problem of "c++ to java" invocation and access. But the other half which is "java to c++ " invocation and access is still not solved. jni only provide the "java to c++ " DLL invocation Wrong,
    Using JNI your java classes can have methods implemented in C/C++.
    Using JNI you can call java classes.
    There is no other possible interaction between C++ and java, so it does it all.

  • How can I use multiple row insert or update into DB in JSP?

    Hi all,
    pls help for my question.
    "How can I use multiple rows insert or update into DB in JSP?"
    I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
    With thanks,

    That isn't true. Different SQL databases have
    different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
    I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
    and there are also a lot of different ways of talking to
    SQL databases that are possible in JSP, from using
    plain old java.sql.* in scriptlets to using the
    jstlsql taglib. I've done maintenance on both, and
    they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
    Well, sure. As long as you only want to update rows
    with the same value in column 2. I had the impression
    he wanted to update a whole table. If he only meant
    update all rows with the same value in a given column
    with the same value, that's trivial. All updates do
    that. But as far as I know there's know way to update
    more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
    Unless you're using MySQL, for instance. I only have
    experience with MySQL and M$ SQL Server, so I don't
    know what PostgreSQL, Oracle, Sybase, DB2 and all the
    rest are capable of, but I know for sure that MySQL
    can insert multiple rows while SQL Server can't (or at
    least I've never seen the syntax for doing it if it
    does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
    Don't assume that all SQL databases are the same.
    They're not, and it can really screw you up badly if
    you assume you can deploy a project you've developed
    with one database in an environment where you have to
    use a different one. Even different versions of the
    same database can have huge differences. I recommend
    you get a copy of the O'Reilly book, SQL in a
    Nutshell. It covers the most common DBMSes and does a
    good job of pointing out the differences.Yes, I understand that.
    It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
    I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
    The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing.

  • OIM - Task Assignment Adapter - How to get the object instance key?

    Hello experts,
    I'm trying to use a task assignment adapter to assign an approval task dynamically. Basically, the user can request a resource like "CustomApp Profiles" and we create an object form to let them choose the profile that he needs. Each profile has an owner, which is populate in a Lookup (Owner is the code and Profile is the decode).
    So, in the approval task, I need to get the profile selected by user in the object form and search into the lookup who is the owner of that profile. But I don't know how can I get the object instance key using the parameters that can be mapped to a task assignment adapter.
    Looking into the OIM documents, I believe that the easier way is using the request key, because the REQ_KEY is a foreign key in OBI table.
    Did anyone knows how can I get the object instance key using the request key? Can I use some API or should I execute a SQL statement directly in OIM database?
    Best Regards,
    Nitto

    To retry a task that is in a rejected state, you use the SCH_KEY which is the task key.  In OIM, all rejected tasks are listed in the OTI table.  It contains all the important information about a rejected or pending task.
    You can use the APIs found in the tcProvisioningOperationsIntf class to retrieve open tasks.
    -Kevin

  • Create SOFM object instance from PDF

    Hi All,
    I am using 4.6 version of SAP where FM 'sap_wapi_attachment_add' is does not exit. My query is to create an attachment (SMARTFORM coverted in PDF) in ABAP progam which i have to send as attachment with a Decision Task in the workflow.
    I am able to send attachment with mail but to send attachment with decision task i need to create an instance of SOFM object. Please suggest an alternative method to do so instead of FM 'sap_wapi_attachment_add' .

    Hi Taran,
    I had put my code in workflow task. You can find the task method code below:
    *Data declaration
    DATA: GITAB     TYPE SOLIX_TAB,                     
          GSTAB     LIKE LINE OF GITAB,                 
          SOFM_KEY  TYPE SOFMK,                         
          GIT_LINES TYPE SOLI_TAB.                      
    DATA: LREF_DOCUMENT_BCS  TYPE REF TO CL_DOCUMENT_BCS,
          LREF_IM_DOCUMENT   TYPE REF TO IF_DOCUMENT_BCS.
    Generate Smartform*
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME                 = C_FORM
    *      VARIANT                  = ' '
    *      DIRECT_CALL              = ' '
        IMPORTING
          FM_NAME                  = GV_FM
        EXCEPTIONS
          NO_FORM                  = 1
          NO_FUNCTION_MODULE       = 2
          OTHERS                   = 3.
      IF SY-SUBRC <> 0.
    *    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
        EXPORTING
          I_LANGUAGE                   = SY-LANGU
    *      I_APPLICATION                = 'SAPDEFAULT'
        IMPORTING
          E_DEVTYPE                    = GV_OUTPUT_OPTIONS-TDPRINTER
        EXCEPTIONS
          NO_LANGUAGE                  = 1
          LANGUAGE_NOT_INSTALLED       = 2
          NO_DEVTYPE_FOUND             = 3
          SYSTEM_ERROR                 = 4
          OTHERS                       = 5.
      IF SY-SUBRC <> 0.
    *    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      GV_OUTPUT_OPTIONS-TDNOPREV = 'X'.
      GV_CONTROL_PARAMETERS-GETOTF = 'X'.
      GV_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
      CALL FUNCTION GV_FM
        EXPORTING
    *      ARCHIVE_INDEX              =
    *      ARCHIVE_INDEX_TAB          =
    *      ARCHIVE_PARAMETERS         =
          CONTROL_PARAMETERS         = GV_CONTROL_PARAMETERS
    *      MAIL_APPL_OBJ              =
    *      MAIL_RECIPIENT             =
    *      MAIL_SENDER                =
          OUTPUT_OPTIONS             = GV_OUTPUT_OPTIONS
          USER_SETTINGS              = 'X'
          GV_ENAME                   = GV_ENAME
          GV_PERNR                   = GV_PERNR
          GV_PERSK                   = GV_PERSK
          GV_ZZ_LEVEL                = GV_ZZ_LEVEL
          GV_BTRTX                   = GV_BTRTX
          GV_GBDAT                   = GV_GBDAT
          GV_JOIN_DATE               = GV_JOIN_DATE
          GV_RESIN_DATE              = GV_RESIN_DATE
        IMPORTING
          DOCUMENT_OUTPUT_INFO       = GV_DOCUMENT_OUTPUT_INFO
          JOB_OUTPUT_INFO            = GV_JOB_OUTPUT_INFO
          JOB_OUTPUT_OPTIONS         = GV_JOB_OUTPUT_OPTIONS
        EXCEPTIONS
          FORMATTING_ERROR           = 1
          INTERNAL_ERROR             = 2
          SEND_ERROR                 = 3
          USER_CANCELED              = 4
          OTHERS                     = 5.
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
    *    EXPORTING
    *      USE_OTF_MC_CMD               = 'X'
    *      ARCHIVE_INDEX                =
        IMPORTING
          BIN_FILESIZE                 = GV_BIN_FILESIZE
        TABLES
          OTF                          = GV_JOB_OUTPUT_INFO-OTFDATA
          DOCTAB_ARCHIVE               = GIT_DOCS
          LINES                        = GIT_LINES_TEMP
        EXCEPTIONS
          ERR_CONV_NOT_POSSIBLE        = 1
          ERR_OTF_MC_NOENDMARKER       = 2
          OTHERS                       = 3.
      IF SY-SUBRC <> 0.
    *    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        TABLES
          CONTENT_IN  = GIT_LINES_TEMP
          CONTENT_OUT = GIT_LINES.
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
        EXPORTING
          IP_SOLITAB  = GIT_LINES   "GIT_LINES_TEMP1
        IMPORTING
          EP_SOLIXTAB = GITAB.
    *Create SOFM object from smartform PDF
    IF NOT GITAB IS INITIAL.                    
          TRY.                                                        
              CALL METHOD CL_DOCUMENT_BCS=>CREATE_DOCUMENT            
                EXPORTING                                             
                  I_TYPE          = 'BIN'                             
                  I_SUBJECT       = 'NOTICE PAY WAIVER FORM'          
    *          I_LENGTH        =                                      
    *          I_LANGUAGE      = SPACE                                
    *          I_IMPORTANCE    =                                      
    *          I_SENSITIVITY   =                                      
    *          I_TEXT          =                                      
                  I_HEX           = GITAB                             
    *          I_HEADER        =                                      
    *          I_SENDER        =                                      
                RECEIVING                                             
                  RESULT          = LREF_DOCUMENT_BCS.                
            CATCH CX_DOCUMENT_BCS .                                   
          ENDTRY.                                                                               
    LREF_IM_DOCUMENT = LREF_DOCUMENT_BCS.                                                                               
    TRY.                                                        
              CALL METHOD LREF_DOCUMENT_BCS->ADD_DOCUMENT_AS_ATTACHMENT
                EXPORTING                                             
                  IM_DOCUMENT = LREF_IM_DOCUMENT.                     
            CATCH CX_DOCUMENT_BCS .                   
          ENDTRY.                                                                               
    TRY.                                        
              CALL METHOD LREF_DOCUMENT_BCS->GET_DOCTP
                RECEIVING                             
                  RESULT = SOFM_KEY-DOCTP.            
            CATCH CX_OS_OBJECT_NOT_FOUND .            
          ENDTRY.                                                                               
    TRY.                                        
              CALL METHOD LREF_DOCUMENT_BCS->GET_DOCYR
                RECEIVING                             
                  RESULT = SOFM_KEY-DOCYR.            
            CATCH CX_OS_OBJECT_NOT_FOUND .            
          ENDTRY.                                                                               
    TRY.                                        
              CALL METHOD LREF_DOCUMENT_BCS->GET_DOCNO
                RECEIVING                             
                  RESULT = SOFM_KEY-DOCNO.            
            CATCH CX_OS_OBJECT_NOT_FOUND .            
          ENDTRY.                                                                               
    SWC_CREATE_OBJECT NOTICE_PAY_WAIVER_FORM 'SOFM' SOFM_KEY.
          SWC_SET_ELEMENT CONTAINER 'NOTICE_PAY_WAIVER_FORM'      
                                     NOTICE_PAY_WAIVER_FORM.      
        ENDIF.
    The object instance thus created will be visible along with other  object instances in the workitem display. Provide this object in binding of decision step as you provise any other obect instance and not as ATTACH_OBJECT       
    Regards,
    Neha

  • Hiberate+JBoss Can Update, Select But Cannot Insert

    Hi there,
    I got this error during insert operation using JBoss 4.2.2 with Hibernate 3:
    org.hibernate.PersistentObjectException: detached entity passed to persist: com.abc.uresdemo.bean.Result
        at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:79)
        at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
        at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
        at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
        at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)I deployed hibernate mapping using SAR and it works fine during server startup.
    Thanks

    Hi there, thanks for the reference, after reading it and tried a few possibilities, I still could not figure out where is the part that I did not use a new Session context to write in the data, So I attach the code blocks that related, kindly please enlighten me, TQ:
    This is the business logic that initiate the call:
    public void loginThenSubmitData(DataUplink dataUplink) throws LoginException, BusinessException {
              log.debug("URESDemoBusinessImpl.loginThenSubmitData");
              LoginManager.getInstance().loginAttempt(dataUplink.getUserId(), dataUplink.getPassword());
              Result result = new Result();
              result.setDeviceId(dataUplink.getDeviceId());
              result.setDeviceParameterId(dataUplink.getDeviceParameterId());
              result.setTimeStamp(dataUplink.getDateTime());
              result.setParameterKey(dataUplink.getParameterKey());
              result.setParameterName(dataUplink.getParameterName());
              result.setResult(dataUplink.getResult());
              result.setLastUpdatedBy(dataUplink.getUserId());
              result.setLastUpdatedDate(GregorianCalendar.getInstance().getTime());
              StatusHome statusHome = new StatusHome();
              String status = statusHome.findById("A").getStatusDescription();
              result.setStatus(status);
              statusHome = null;
              ResultHome resultHome = new ResultHome();
              resultHome.persist(result);
    ...Then LoginManager class:
    public final class LoginManager {
          * Local {@link Log} instance
         private static Log log = LogFactory.getLog(LoginManager.class);
          * Local instance of {@link LoginManager}
         private static LoginManager instance;
          * Local instance of {@link UsersHome}
         protected UsersHome usersHome = null;
          * Hides default constructor
         private LoginManager() {
          * Return the instance of {@link LoginManager}
          * @return {@link LoginManager}
         public static LoginManager getInstance() {
              log.debug("instantiate LoginManager");
              if (instance == null) {
                   instance = new LoginManager();
              return instance;
          * Autheticate user login using user name and password
          * @param username
          *            {@link String}
          * @param password
          *            {@link String}
          * @return {@link Boolean#booleanValue()}
          * @throws LoginException
         public void loginAttempt(String username, String password) throws LoginException {
              log.debug("loginAttempt");
              if (null != username && null != password && !"".equals(username) && !"".equals(password)) {
                   usersHome = new UsersHome();
                   Users users = usersHome.findById(username);
                   if (null != users && password.trim().equals(users.getLoginPassword().trim())) {
                        return;
                   } else {
                        @SuppressWarnings("unused")
                        LoginException loginException = new LoginException(LoginException.LOGIN_FAILED);
                        throw new LoginException();
              } else {
                   @SuppressWarnings("unused")
                   LoginException loginException = new LoginException(LoginException.LOGIN_INVALID);
                   throw new LoginException();
    }ResultHome extends EntityHome:
    public void persist(Result transientInstance) {
              log.debug("persisting Result instance");
              try {
                   transientInstance.setTransactionId(getNextHiloSequenceInString(EntityHome.HILOSEQ_TRANSAQID));
                   writePersist(transientInstance);
                   log.debug("persist successful");
              } catch (RuntimeException re) {
                   log.error("persist failed", re);
                   throw re;
    ...StatusHome extends EntityHome:
    public Status findById(java.lang.String id) {
              log.debug("getting Status instance with id: " + id);
              try {
                   Status instance = (Status) getSessionInstance().get("com.chilliwire.uresdemo.bean.Status", id);
                   if (instance == null) {
                        log.debug("get successful, no instance found");
                   } else {
                        log.debug("get successful, instance found");
                   return instance;
              } catch (RuntimeException re) {
                   log.error("get failed", re);
                   throw re;
    ...And EntityHome:
    public class EntityHome {
          * Client ID hilo sequences key constant
         public static final String HILOSEQ_CLIENTID = "CLIENT_ID";
          * Network ID hilo sequences key constant
         public static final String HILOSEQ_NETWORKID = "NETWORK_ID";
          * Device parameter ID hilo sequences key constant
         public static final String HILOSEQ_DEVICEPARAMID = "DEV_PARAM_ID";
          * Supervisor ID hilo sequences key constant
         public static final String HILOSEQ_SUPERVISORID = "SUPERVISOR_ID";
          * Transaction ID hilo sequences key constant
         public static final String HILOSEQ_TRANSAQID = "TRANQ_ID";
          * {@link Map} to keep keys' values of hilo sequences
         private Map<String, String> keyMap = new HashMap<String, String>();
          * {@link Log} instance
         private final Log log = LogFactory.getLog(EntityHome.class);
          * Instantiate {@link SessionFactory} during creation
         final SessionFactory sessionFactory = getSessionFactory();
          * Instance of {@link Session}
         protected Session session = null;
          * Default constructor
         public EntityHome() {
              loadResourceBundle();
          * Resource bundle loader
         private void loadResourceBundle() {
              ResourceBundle resourceBundle = ResourceBundle.getBundle("hilo");
              if (resourceBundle != null) {
                   Enumeration<String> enu = resourceBundle.getKeys();
                   while (enu.hasMoreElements()) {
                        String s = enu.nextElement();
                        keyMap.put(s, resourceBundle.getString(s));
          * Return instance of {@link Session}
          * @return {@link Session}
         protected Session getSessionInstance() {
              if (session == null || !session.isOpen()) {
                   session = sessionFactory.openSession();
              return session;
          * Return instance of {@link SessionFactory}
          * @return {@link SessionFactory}
         private SessionFactory getSessionFactory() {
              try {
                   return (SessionFactory) new InitialContext()
                             .lookup("SessionFactory");
              } catch (Exception e) {
                   log.error("Could not locate SessionFactory in JNDI", e);
                   throw new IllegalStateException(
                             "Could not locate SessionFactory in JNDI");
          * Overriding {@link org.hibernate.Session#persist(Object)} embed with
          * {@link org.hibernate.Session#beginTransaction()} and
          * {@link Transaction#commit()}
          * @param transientInstance
          *            {@link Object}
         protected void writePersist(Object transientInstance) {
              getSessionInstance().beginTransaction();
              getSessionInstance().persist(transientInstance);
              getSessionInstance().getTransaction().commit();
          * Overriding {@link org.hibernate.Session#saveOrUpdate(Object)} embed with
          * {@link org.hibernate.Session#beginTransaction()} and
          * {@link Transaction#commit()}
          * @param instance
          *            {@link Object}
         protected void writeSaveOrUpdate(Object instance) {
              getSessionInstance().beginTransaction();
              getSessionInstance().saveOrUpdate(instance);
              getSessionInstance().getTransaction().commit();
          * Overriding {@link org.hibernate.Session#merge(Object)} embed with
          * {@link org.hibernate.Session#beginTransaction()} and
          * {@link Transaction#commit()}
          * @param instance {@link Object}
         protected void merge(Object instance) {
              getSessionInstance().beginTransaction();
              getSessionInstance().merge(instance);
              getSessionInstance().getTransaction().commit();
          * Return the next {@link Hilosequences#getHighvalues()}
          * @param sequenceName
          *            {@link EntityHome#HILOSEQ_TOPUP} or
          *            {@link EntityHome#HILOSEQ_REG}
          * @return {@link Integer#intValue()}
         protected int getNextHiloSequence(String sequenceName) {
              int nextHighValue = 1;
              HilosequencesHome hilosequencesHome = new HilosequencesHome();
              Hilosequences hilosequences = hilosequencesHome.findById(keyMap
                        .get(sequenceName));
              if (hilosequences != null) {
                   nextHighValue = hilosequences.getHighvalues() + 1;
                   hilosequences.setHighvalues(nextHighValue);
                   hilosequencesHome.attachDirty(hilosequences);
              } else {
                   hilosequences = new Hilosequences();
                   hilosequences.setSequencename(keyMap.get(sequenceName));
                   hilosequences.setHighvalues(nextHighValue);
                   hilosequencesHome.persist(hilosequences);
              return nextHighValue;
          * String implementation of {@link EntityHome#getNextHiloSequence(String)} method
          * @param sequenceName {@link String}
          * @return {@link String}
         protected String getNextHiloSequenceInString(String sequenceName) {
              return String.valueOf(getNextHiloSequence(sequenceName));
         }

  • Static Classes/Methods vs Objects/Instance Classes/Methods?

    Hi,
    I am reading "Official ABAP Programming Guidelines" book. And I saw the rule:
    Rule 5.3: Do Not Use Static Classes
    Preferably use objects instead of static classes. If you don't want to have a multiple instantiation, you can use singletons.
    I needed to create a global class and some methods under that. And there is no any object-oriented design idea exists. Instead of creating a function group/modules, I have decided to create a global class (even is a abstract class) and some static methods.So I directly use these static methods by using zcl_class=>method().
    But the rule above says "Don't use static classes/methods, always use instance methods if even there is no object-oriented design".
    The book listed several reasons, one for example
    1-) Static classes are implicitly loaded first time they are used, and the corresponding static constructor -of available- is executed. They remain in the memory as long as the current internal session exists. Therefore, if you use static classes, you cannot actually control the time of initialization and have no option to release the memory.
    So if I use a static class/method in a subroutine, it will be loaded into memory and it will stay in the memory till I close the program.
    But if I use instance class/method, I can CREATE OBJECT lo_object TYPE REF TO zcl_class then use method lo_object->method(), then I can FREE  lo_object to delete from the memory. Is my understanding correct?
    Any idea? What do you prefer Static Class OR Object/Instance Class?
    Thanks in advance.
    Tuncay

    @Naimesh Patel
    So you recommend to use instance class/methods even though method logic is just self-executable. Right?
    <h3>Example:</h3>
    <h4>Instance option</h4>
    CLASS zcl_class DEFINITION.
      METHODS add_1 IMPORTING i_input type i EXPORTING e_output type i.
      METHODS subtract_1 IMPORTING i_input type i EXPORTING e_output type i.
    ENDCLASS
    CLASS zcl_class IMPLEMENTATION.
      METHOD add_1.
        e_output = i_input + 1.
      ENDMETHOD.
      METHOD subtract_1.
        e_output = i_input - 1.
      ENDMETHOD.
    ENDCLASS
    CREATE OBJECT lo_object.
    lo_object->add_1(
      exporting i_input = 1
      importing e_output = lv_output ).
    lo_object->subtract_1(
      exporting i_input = 2
      importing e_output = lv_output2 ).
    <h4>Static option</h4>
    CLASS zcl_class DEFINITION.
      CLASS-METHODS add_1 IMPORTING i_input type i EXPORTING e_output type i.
      CLASS-METHODS subtract_1 IMPORTING i_input type i EXPORTING e_output type i.
    ENDCLASS
    CLASS zcl_class IMPLEMENTATION.
      METHOD add_1.
        e_output = i_input + 1.
      ENDMETHOD.
      METHOD subtract_1.
        e_output = i_input - 1.
      ENDMETHOD.
    ENDCLASS
    CREATE OBJECT lo_object.
    lo_object->add_1(
    zcl_class=>add_1(
      exporting i_input = 1
      importing e_output = lv_output ).
    lo_object->subtract_1(
    zcl_class=>subtract_1(
      exporting i_input = 2
      importing e_output = lv_output2 ).
    So which option is best? Pros and Cons?

  • "OIP-04796 Unable to create object instance"

    I am using OO4O, version 3 for Oracle 8.1.7 on Windows with Visual Basic version 6.
    I am getting the intermittent errors "OIP-04796 Unable to create object instance" and also "Method createDynaset of _IOraDatabase failed" - I think both are related to one another and from the documentation for OO4O, "OIP-04796" relates to the client side object cache of the OraDatabase class. Reasoning that the client side object cache was too small I attempted to increase the relevant properties of the OraDatabase object using the following: -
    MyOraDatabaseObj.CacheOptimalSize = 400
    However, at run-time, this property of the OraDatabase object does not get set accordingly in the VB IDE and after several attempts I can't seem to set it. I have also tried setting the CacheMaximumSize property but to no avail.
    Can anybody indicate to me where I am going wrong and either with the setting of the above properties or with the error message in general if I am not on the right track with the cache properties. I don't suspect that it is my code because the problem "seems" to be intermittent.
    Any and all help would be greatly appreciated. If more info is required then just ask as this is pressing problem.
    TYIA
    Mark Grimshaw

    I am pretty sure the patches are available here. If you didn't explicitly install one then you have whatever the base release was.
    If they are not available here (I almost never look here first for a patch) they are certainly available in the MetaLink file library for OO4O.

  • Workflow N-Step value .Object instance BUS4101 message when released

    Hi Everybody,
    Onw customer running BBPCRM40 SP 8
    We are using N-Step Approval over value Limit of Shopping Cart WS14000109
    When a shopping cart is released, another message appear in inbox about,
    Object instance BUS4101, with several message about field values doesn't exist.
    I have seen several notes like 905409 but it doesn't apply for my version level,
    Does anybody know why this message appear and how I can omit it?
    Thanks
    Best regards

    The message translated would be Work item <WORKITEM.WORKITEMSHORTTEXT not found>" (identif. <WORKITEM.WORKITEMID not found> type <WORKITEM.WORKITEMTYPE not found> in status <WORKITEM.WORKITEMSTATUS not found>.
    Make a correction action for workflow <WORKITEM.WORKITEMREFERENCE not found> might be updated.
    I hope this help
    Regards

  • How to remove all scripts on object instances?

    I'm looking for any kind of solution here, besides disabling the warning.
    I hate it when I'm converting someone else's AS2 project to AS3, and there's code buried on an onstage instance somewhere, which gives me the warning:
    "Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored."
    How can I:
         A) Find which instances have code on them.
              or
         B) Remove all code on all instances.
    Idea:
    Can I save as a different format/version/something and lose this data somehow. Then I could convert it back its current FLA format?

    YES!!! So awesome!!  Thanks

  • Transient java object instance from jvm through jni?

    Hello, All
    Sometimes I want manage the memory take by object instance,
    for example, If I want to design a cache which cache a huge number object.
    Then, there may two problems:
    1, May occur OutOfMemory error.
    2, I want like to manually reclaim the memory take by the cached object,
    not by gc, because it may take a little time to check the reference for gc.
    Just as you know, there is keyword transient for serialization.
    I want know if some same mechanism for object instance creating or release, managing memory by jni, or by some other way?

    No, since you're not supposed to do that. hence you can't really expect Java to provide the means...
    Maybe you can use classes like WeakReference etc. but that won't bypass GC.

  • Share Java Object Instance between JSP's

    Hi@all!
    Can i share a Java Object Instance between JSPages?
    Example:
    Class x
    Public Attribute txt
    Object creation in x.jsp
    set public Attribute txt to "HelloWorld"
    goto y.jsp
    get value from txt
    or...
    a global package
    thnx for help

    Here is a tutorial that explains how to use jsps and javabeans together.
    http://www.roseindia.net/jsp/usingbeansinjsp.shtml
    Quick question is sounds like you are pretty early in your development phase. Have you considered adopting JSF. You may find it a bit easier.
    Regards.

  • What is the difference between object, instance, referance?

    What is the difference between object, instance, referance of a class? write some code for that, that will be easy to understand for me.
    Thank you.

    petes1234 wrote:
    paul.miner wrote:
    You'll get a more useful reply if you ask a better question. As it is, your question is overly broad and vague. I beg to differ. I found it direct and to the point: "Please do my homework".I too found it direct but not like that.
    I translated the request as "I am just starting to learn Java and don't understand any of the basic concepts. Could I please have some code that could maybe explain this concepts more clearly so that I can get a practical sense of them?"
    And the answer is... the tutorial.
    I agree the second sentence reads to you and I (and probably others) as demanding, but I think it's just an ESL issue. He/she at least said thanks.

  • Reusing a variable from a new object instance

    I'm developing a stock list array for an assignment I'm currently working on. I've got most of it done, and it seems to be working for the most part, but I'm having trouble getting an array to accept individual variable entries created by new object instances in TestQ3.java.
    I think problem is because the variable itemCode in CraftItem.java is being overwritten by the creation of a new object instance in the TestQ3.java file. I've tested it and believe this to be true.
    I can add a String of my own choosing by using testArray.addCraftItemToStock(itemCode); line but I want to get the program to reuse the itemCode values that have already been created by the four new object instances in TestQ3.java. For example, I want to be able to add more instances of them to the testArray.
    As I'm still relatively new to Java programming, I'm wondering how to do this. I've tried several solutions but I'm not getting anywhere. I'd appreciate it if anyone has any ideas?
    Here's my code:
    TestQ3.java
    public class TestQ3 {
      public static void main(String args[]) {
        // creating a new StockItem array
        CraftStock testArray = new CraftStock(CraftStock.initialStockCapacity);
        // creating new object instance for Glue
        Glue gluePVA = new Glue("PVA Glue",250,"789012",2.50);
        // adds gluePVA item code to the testArray list
        // testArray.addCraftItemToStock(gluePVA.getItemCode());
        // creating new object instance for Card
        Card colouredCard = new Card ("Coloured Card","A3","654321",1.25);
        // adds coloured card item code to the testArray list
        // testArray.addCraftItemToStock(colouredCard.getItemCode());
        // creating new object instance for Glue
        Glue superGlue = new Glue ("Super Glue",25,"210987",1.50);
        // adds superGlue item code to the testArray list
        // testArray.addCraftItemToStock(superGlue.getItemCode());
        // creating new object instance for Card
        Card whiteCard = new Card ("White Card","A4","123456",0.50);
        // adds superGlue item code to the testArray list
        // testArray.addCraftItemToStock(whiteCard.getItemCode());
        // display complete stocklist
        testArray.displayCraftStockList();
        // this adds the itemCode from gluePVA to the array but
        // it comes out as the last itemCode entry 123456 rather than 789012
        // when I run the code. The problem may lie with variable itemCode
        testArray.addCraftItemToStock(gluePVA.getItemCode());
        // display complete stocklist
        testArray.displayCraftStockList();
    CraftItem.java
    public class CraftItem {
      // instance variables
      public static String itemCode;
      private double price;
      //private int stockCount;
      // constructor
      public CraftItem(String itemCodeValue, double itemPriceValue){
        itemCode = itemCodeValue;
        price = itemPriceValue;
        //CraftStock.addCraftItemToStock(itemCode);
        //stockCount++;
      // getter for itemCode
      public String getItemCode() {
        return itemCode;
      // getter for price
      public double getPrice() {
        return price;
      // setter for itemCode
      public void setItemCode(String itemCodeValue) {
        itemCode = itemCodeValue;
      // setter for price
      public void setPrice(double itemPriceValue) {
        price = itemPriceValue;
      // toString() value
      public String toString() {
        return "Item code is " + itemCode + " and costs " + price + " pounds.";
    Glue.java
    public class Glue extends CraftItem{
      // Instance variables
      private String glueType;
      private double glueVolume;
      // Constructor
      public Glue(String glueType, double glueVolume,
       String itemCodeValue, double itemPriceValue) {
            super(itemCodeValue, itemPriceValue);
            glueType = glueType;
            glueVolume = glueVolume;
      // getter
      public String getGlueType() {
        return glueType;
      // getter
      public double getGlueVolume() {
        return glueVolume;
      // setter
      public void setGlueType(String glueTypeValue) {
        glueType = glueTypeValue;
      public void setGlueVolume(double glueVolumeValue) {
        glueVolume = glueVolumeValue;
      // toString
      public String toString() {
        return glueType + ", " + glueVolume + "ml, item code is "
         + super.getItemCode() + " and costs " + super.getPrice() + " pounds.";
    Card.java
    public class Card extends CraftItem{
      // instance variables
      private String cardType;
      private String cardSize;
      // Constructor
      // added super(itemCodeValue, itemPriceValue) to call on CraftItem
      public Card(String cardTypeValue, String cardSizeValue,
       String itemCodeValue, double itemPriceValue) {
            super(itemCodeValue, itemPriceValue);
            cardType = cardTypeValue;
            cardSize = cardSizeValue;
      // getter
      public String getCardType() {
        return cardType;
      // getter
      public String getCardSize() {
        return cardSize;
      // setter
      public void setCardType(String cardTypeValue) {
        cardType = cardTypeValue;
      // setter
      public void setCardSize(String cardSizeValue) {
        cardSize = cardSizeValue;
      // toString
      // using super. to call on methods from superclass CraftItem
      public String toString() {
        return cardType + ", size " + cardSize + ", item code is "
         + super.getItemCode() + " and costs " + super.getPrice() + " pounds.";
    CraftStock.java
    public class CraftStock {
        public static int currentStockLevel;
        public static String[] craftStock;
        public static int initialStockCapacity = 10;
        public CraftStock(int initialStockCapacity) {
            currentStockLevel = 0;
            craftStock = new String[initialStockCapacity];
        public int currentStockLevel() {
            return currentStockLevel;
        public static void addCraftItemToStock(String itemCodeValue) {
            if(currentStockLevel == 10){
              System.out.println("Stock list full: cannot add new item code." +
                "\nPlease remove an item if you want to add a new one.");
            else{
            craftStock[currentStockLevel] = itemCodeValue;
            currentStockLevel++;
            System.out.println("Item added");
        public void removeCraftItemFromStock(String itemCode){
          findStockItem(itemCode);
          int i = -1;
            do {
                i++;
            } while (!craftStock.equals(itemCode));
    for (int j = i; j < currentStockLevel - 1; j++) {
    craftStock[j] = craftStock[j + 1];
    currentStockLevel--;
    System.out.println("Item removed");
    private int findStockItem(String itemCode){
    int index = 0;
    for(int i = 0; i < currentStockLevel; i++){
    if(craftStock[i].equals(itemCode)){
    index = i;
    break;
    else{
    index = -1;
    return index;
    public void displayCraftStockList() {
    if(currentStockLevel == 0){
    System.out.println("There are no items in the stock list");
    else{
    for(int i = 0; i < currentStockLevel; i++){
    System.out.println("Item at " + (i + 1) + " is " + craftStock[i]);
    Message was edited by:
    Nikarius

    An instance variable relates to an object. If you require a variable to be available across multiple objects of the same class then I suggest you declare a class variable using the static keyword in your declaration.
    HTH

  • Refering to object instances from a jsp

    How can i call object instances within class instances in my application -- from a jsp?
    In other words, i want to reference to an pre-existing application instance of a class.
    I do not want "use:bean" -- which will use a class (not the specific instance i am looking for in the application).
    I also do not want a binding to a variable only ( #{class.variable} ).
    Thank You!
    eric

    That's a good reminder of how to positively access class2, stevejluke. Thanks.
    However, i have found by trying to access a simple String in Class1 that the class1 instantiated by the jsf page (this comes up first in the application and has components which require Class1) is not the same instantiation that being accessed by the jsp page (which is navigated to by a button from the jsf page).
    I put:
    <jsp:useBean id="myBean" class="com.mycompany.expense.EntryHandler" scope="session"/>
    at the top of both the jsf and the jsp page.
    faces-config.xml has:
    <managed-bean>
    <description>
    Glue bean for entry related events and the current entry data
    </description>
    <managed-bean-name>entryHandler</managed-bean-name>
    <managed-bean-class>
    com.mycompany.expense.EntryHandler
    </managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property> ((about 4)) <managed-property>
    <managed-bean>
    I tried setting <managed-bean-name> equal to the id in the jsp:useBean tag but drew the an error indicating the the <jsp:useBean ...> tag had instantiated the class before the faces-config.xml file had -- hence the managed property could not be found.
    I also tried putting name="entryHandler" in the <jsp:useBean > tag, but this is not allowed.
    Hmm, how to get the <managed-bean> and <jsp:useBean> to match?
    Maybe i have to put in code to the effect "get context " "get instantiation" etc,
    I'll have to try looking it up . . .

Maybe you are looking for

  • Need some Big help pro-100

      Hello, everyone first time here, but i have been reading the forums for the past 2 weeks.   My wife just bought a Pro-100 printer 2 weeks ago, and we are haveing nothing but problems setting this thing up.  I'v been on youtube, and different forums

  • Filter unassigned values in report output

    Hi Friends, I have a requirement as explained below. There is a variable for Document Number with Select Options in the selection screen. There are some documents which come as unassigned in BW, When I execute the query leaving this document no field

  • IPod stopped completly!!! Help!!!

    My iPod Video, ive had it for around 6 months, just stopped working I turned it on, and it displays the song screen as that was what it displayed when i last turned it off, but it is completly frozen on this screen. It wont play, change screen, turn

  • Who will have access to data grid

    do end user can have access to Data Grid. general who will have access to data grid i.e both end user and hfm developer can access to the data grid in real time. Can any one pls tell Thanx

  • Improvement of Period-End Closing Utiltity

    Hello. Currently I've been trying to test and review SAP 8.8 Preview version. The reason I create this message is that I hope There will be some improvement of Period-End Closing functionality. in the case of Account Segmentation, Financial Reporting