How to create new java objects in native methods?

Hello,
Is it possible to create java objects and return the same to the java code from a native method?
Also is it possible to pass java objects other than String objects (for example, Vector objects) as parameters to native methods and is it possible to return such objects back to the java code?
If so how can I access those objects (say for example, accessing Vector elements) inside the native code?
What should I do in order to achieve them?
Regards,
Satish

bschauwe is correct in that constructing Java objects and calling methods on Java objects from native code is tough and takes some study. While you're at it, you might want to check out Jace, http://jace.reyelts.com/jace. It's a free open-source toolkit that really takes the nastiness out of doing this sort of stuff. For example,/**
* A C++ function that takes a java.util.Vector and plays around with it.
public void useVector( java::util::Vector& vector ) {
  // Print out all the contents of the vector
  for ( Iterator it = vector.iterator(); it.hasNext(); ) {
    cout << it.next();
  // Add some new elements to the vector
  vector.addElement( "Hello" );
  vector.addElement( "world" );
} All this code just results in calls to standard JNI functions like FindClass, NewObject, GetMethodID, NewStringUTF, CallObjectMethod, etc...
God bless,
-Toby Reyelts

Similar Messages

  • How to create new authorisation object for Transactions?

    Hi,
    How to create new authorisaton object and how to assign that object on a transaction code?
    Case ->
    The transaction code VL01N have the object called V_LIKP_VST under Class "LE_V" that have two auth. fields. one is 'Activity' and other one is "Shipping Point/Receiving Point".
    Here I want to add "Storage location" also. I have created one object called "Z_LIKP_VST" under same calass "LE_V". and added "Activity", "Shipping Poing/Receiving Poing" and "Storage Location". After that I added that object ("Z_LIKP_VST") for particular transaction through "SU24". I maintained the "Display check indicator" for VL01N.
    I created one new role and assigend the particular transacation for a user. but still SAP taking  V_LIKP_VST insted of Z_LIKP_VST.
    How can I change my Z_LIKP_VST on profile.
    Please help
    Thanks in Advance
    Lal

    Hi Kariyath,
    I suppose its not about interest but a MUST.. sorry but.. unless u include the Logic in the program how can SAP pick these custom Z objects ?
    after u create them and assign to a Tcode in SU24 there is no logic to check these objects. Frankly i see no other chance.... unless SAP comes to us with a great easy way to input these Custom objects
    Keep looking and please Update me if u have any Inputs....on this front..
    All the Best
    Br,
    Sri
    Award points for helpful answers

  • How to create a Java Object dynamically

    I want to convert a "DataObject (SDO) " into "Pure java object".
    For this i want to create a java object with the fields in Dataobject, and this should be in generic way.

    I want to convert a "DataObject (SDO) "What is a "DataObject (SDO)"?
    into "Pure
    java object".What is a "Pure java object"?
    For this i want to create a java object with the
    fields in Dataobject, What is stopping you? Do you not know how do define a class? Do you think you can add fields to the Object class? If that's what you mean, you're out of luck.
    and this should be in generic
    way.What do you mean "in generic way"? "Generic" is a very generic term. There are lots of contexts in which it could apply and lots of different possible meanings for "generic way."
    You'll have to explain your queston more clearly.

  • How to create new bol object  for  BT in sap crm

    HI
         I need to create new bol for BT with relationship  with out using AET ,Could you please explain step by step.
    Thanks and best regards
    Brahmaiah

    Hi Kariyath,
    I suppose its not about interest but a MUST.. sorry but.. unless u include the Logic in the program how can SAP pick these custom Z objects ?
    after u create them and assign to a Tcode in SU24 there is no logic to check these objects. Frankly i see no other chance.... unless SAP comes to us with a great easy way to input these Custom objects
    Keep looking and please Update me if u have any Inputs....on this front..
    All the Best
    Br,
    Sri
    Award points for helpful answers

  • How to create new program object in 3.1

    Hello Experts,
    I created a java program and would like to publish it to BO XI 3.1
    But I donot find any "Objects mangement area of the CMC" in 3.1 as we have it in XI R2.
    Thanks,
    Praveen.

    As there is no more objects section in 3.x it was moved to the BOE applications > central management server > right click (one of the 3 options)
    Regards,
    Tim

  • How to create new XML file using retreived XML content by using SAX API?

    hi all,
    * How to create new XML file using retreived XML content by using SAX ?
    * I have tried my level best, but output is coming invalid format, my code is follows,
    XMLFileParser.java class :-
    import java.io.StringReader;
    import java.io.StringWriter;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.sax.SAXSource;
    import javax.xml.transform.sax.SAXTransformerFactory;
    import javax.xml.transform.sax.TransformerHandler;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.XMLFilterImpl;
    public class PdfParser extends XMLFilterImpl {
        private TransformerHandler handler;
        Document meta_data;
        private StringWriter meta_data_text = new StringWriter();
        public void startDocument() throws SAXException {
        void startValidation() throws SAXException {
            StreamResult streamResult = new StreamResult(meta_data_text);
            SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            try
                handler = factory.newTransformerHandler();
                Transformer transformer = handler.getTransformer();
                transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                handler.setResult(streamResult);
                handler.startDocument();
            catch (TransformerConfigurationException tce)
                System.out.println("Error during the parse :"+ tce.getMessageAndLocation());
            super.startDocument();
        public void startElement(String namespaceURI, String localName,
                String qualifiedName, Attributes atts) throws SAXException {
            handler.startElement(namespaceURI, localName, qualifiedName, atts);
            super.startElement(namespaceURI, localName, qualifiedName, atts);
        public void characters(char[] text, int start, int length)
                throws SAXException {
            handler.characters(text, start, length);
            super.characters(text, start, length);
        public void endElement(String namespaceURI, String localName,
                String qualifiedName) throws SAXException {
            super.endElement("", localName, qualifiedName);
            handler.endElement("", localName, qualifiedName);
        public void endDocument() throws SAXException {
        void endValidation() throws SAXException {
            handler.endDocument();
            try {
                TransformerFactory transfactory = TransformerFactory.newInstance();
                Transformer trans = transfactory.newTransformer();
                SAXSource sax_source = new SAXSource(new InputSource(new StringReader(meta_data_text.toString())));
                DOMResult dom_result = new DOMResult();
                trans.transform(sax_source, dom_result);
                meta_data = (Document) dom_result.getNode();
                System.out.println(meta_data_text);
            catch (TransformerConfigurationException tce) {
                System.out.println("Error occurs during the parse :"+ tce.getMessageAndLocation());
            catch (TransformerException te) {
                System.out.println("Error in result transformation :"+ te.getMessageAndLocation());
    } CreateXMLFile.java class :-
    Sax.startDocument();
    Sax.startValidation();
    Sax.startElement("", "pdf", "pdf", new AttributesImpl());
    Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());          
    String xmp_str = new String(meta_data.getByteArray(),"UTF8");
    char[] xmp_arr = xmp_str.toCharArray();
    Sax.characters(xmp_arr, 0, xmp_arr.length);
    Sax.endElement("", "pdf", "pdf");
    Sax.endValidation();
    Sax.endDocument();
    Sax.endElement("", "basic-metadata", "basic-metadata");* In CreateXMLFile.java
    class, I have retreived the xml content in the meta_data object, after that i have converted into character array and this will be sends to SAX
    * In this case , the XML file created successfully but the retreived XML content added as an text in between basic-metadata Element, that is, retreived XML content
    is not an XML type text, it just an Normal text Why that ?
    * Please help me what is the problem in my code?
    Cheers,
    JavaImran

    Sax.startDocument();
    Sax.startValidation();
    Sax.startElement("", "pdf", "pdf", new AttributesImpl());
    Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());          
    String xmp_str = new String(meta_data.getByteArray(),"UTF8");
    char[] xmp_arr = xmp_str.toCharArray();
    Sax.characters(xmp_arr, 0, xmp_arr.length);
    </code><code>Sax.endElement("", "basic-metadata", "basic-metadata");</code>
    <code class="jive-code jive-java">Sax.endElement("", "pdf", "pdf");
    Sax.endValidation();
    Sax.endDocument();     
    * I HAVE CHANGED MY AS PER YOUR SUGGESTION, NOW SAME RESULT HAS COMING.
    * I AM NOT ABLE TO GET THE EXACT OUTPUT.,WHY THAT ?
    Thanks,
    JavaImran{code}

  • ADF Faces: RichTable - How to create a RichTable object

    Hi. How to create a RichTable object to put in a JSF page ? I need to make a method that receive a list of name of columns and a list of list of data. This code that I have writing don't work. What's my error?
            public RichTable getADFTable(
            List<String> lstCols, List< List<String> > lstLstData
            RichColumn adfCol = null;
            List<RichColumn> lstRichCols = new ArrayList<RichColumn>();
            int cont = 0;
            for( String col : lstCols ){
                adfCol = new RichColumn();
                adfCol.setDisplayIndex(cont++);
                adfCol.setHeaderText( col );
                adfCol.setMinimumWidth( "60" );
                lstRichCols.add( adfCol );
            int contCols = 0;
            RichOutputText text = null;
            RichTable AdfTab = new RichTable();
            for( List<String> lstData : lstLstData){
                for( String data : lstData ){
                    text = new RichOutputText();
                    text.setValue(data);
                    lstRichCols.get( contCols ).getChildren().add( text );
                    contCols++;
                contCols = 0;
            AdfTab.setRows(this.lstEntit.size());
            cont = 0;
            for( RichColumn col : lstRichCols ){
                AdfTab.getChildren().add( col );
            return AdfTab;
        }

    I was searching for an example and i found it but whit errors, finally i fixed and it works.
    You just have to generate the data from your webservices and "put" into this structure.
    The java file (Bean)
    package view;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import org.apache.myfaces.trinidad.model.CollectionModel;
    import org.apache.myfaces.trinidad.model.SortableModel;
    public class DynamicTable {
        private SortableModel model;
        private List<String> columnNames;
        public DynamicTable() {
            columnNames = new ArrayList<String>();
            columnNames.add("Col-1");
            columnNames.add("Col-2");
            generateColumnModel();
        public void generateColumnModel() {
            this.model = new SortableModel(createRows(columnNames));
        private List<Map> createRows(List<String> columnNames) {
            int i = 0;
            List<Map> mapListforRows = new ArrayList<Map>();
            for (String name : columnNames) {
                Map newRow = new HashMap();
                mapListforRows.add(newRow);
                for (String col : columnNames) {
                    newRow.put(col, "data");
            return mapListforRows;
        // Get table model
        public CollectionModel getCollectionModel() {
            return model;
        public void setColumnNames(List<String> columnNames) {
            this.columnNames = columnNames;
        public List<String> getColumnNames() {
            return columnNames;
    }The jspx file (page)
               <af:table varStatus="rowStat" summary="table"
                            value="#{pageFlowScope.DynamicTable.collectionModel}"
                            rows="#{pageFlowScope.DynamicTable.collectionModel.rowCount}"
                            rowSelection="none" contentDelivery="immediate"
                            var="row" rendered="true" id="t1">
                    <af:forEach items="#{pageFlowScope.DynamicTable.columnNames}"
                                var="name">
                      <af:column sortable="true" sortProperty="#{name}"
                                 rowHeader="unstyled" headerText="#{name}"
                                 inlineStyle="width:100px;" id="c1">
                        <af:activeOutputText value="#{row[name]}" id="aot1"/>
                      </af:column>
                    </af:forEach>
                  </af:table>

  • How to create a view object and attach with extended AM

    Hi,
    I tried to create new vo and attach this vo with the extended AM. But it is throwing error like 'PC.NAME : invalid identifier' (Actually this PC.NAME is exiting one).
    Now i want to know how to create a view object similar like seeded one but with one additional condition in the where clause.
    It is possible though extension, but i want to create two view object similar like seeded one, one with some other condition in the where clause
    and another one with some other condition.
    So for my requirement, i'll extend one VO and i'll add my condition but how to do it for second condition.
    But i want same seeded VO with two different condition.
    Any suggestions please,
    SAN

    SAN,
    There is no need to attach the newly created VO with extended AM. You need to attach the same with the standard AM.
    Regards,
    Gyan

  • How to retrieve the java object in a proxy service in osb -- Plz help

    Hi all,
    I have a singleton java class which runs whenever the weblogic server gets started and store the output in its object. I need to access this java object from a proxy service in osb.
    We tried using java call out and retrieved that object but we couldn't know how to parse that object into XML.
    We are not sure of using the java call out in osb to solve this purpose because whenever we use a java callout, that particular java code will run which is not the case of singleton class.
    So kindly help us how to retrieve the java object which holds the output without running the java code every time because its already run and holding the output in its object.
    Regards
    Prabhu

    here the doc http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/context.html#wp1106656
    but I guess you are already at the stage of getting a POJO in a first Java Callout and passing the POJO to a second Java Callout, which should then return it to OSB as a XMLObject.
    My recommendation is to write a Java function which returns a XMLObject and uses a XMLCursor to populate it with the values of the POJO.
    An XMLObject returned to the OSB is automatically transformed in a "XML" variable (which in reality is represented as a XMLObject in the Pipeline context)
    Here some code sample:
    http://www.javamonamour.org/2010/09/how-to-create-xmlobject-using-xmlcursor.html

  • How we create new data base in oracle 10g express edition

    hello every body.. i student of B tech n new user of oracle so please help me how we creat new data base in oracle 10g express edition

    Hello, Oracle XE can not create more than one instance, the other editions yes, but like other editions XE allows you to create database schemas, schemas logically grouped objects like tables, views, indexes created by a user. By creating an Oracle user is associated with a schema of the same name.
    Using SYS or system accounts for creating user accounts.
    Syntax to create a user:
    create user Your_user
    IDENTIFIED BY password
    default tablespace users;
    grant connect, resources to your_user;
    Edited by: rober584812 on Jun 25, 2010 9:03 PM

  • How to create new or delete the existing row in the grid....

    hi my friends...
    i am developing report using Reuse_alv_grid_display...
    my requirement is... At runtime
              1.  i may create new row on the grid (empty row inwhich  i may enter the data).
              2.  i may delete a existing row in the grid
              3.  i may edit the existing data...
    then i have to trace the modification in the grid in one internal table...
    how can i get into this.....
    note:
    i have some idea to edit the existing record in the grid and trace those modification,
    but i don't know abt how to create new or delete the existing row....
    can you give me some idea...

    Hi deva,
    write a class which implemets these methods
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
    To handle the toolbar on alv
         handle_toolbar
           FOR EVENT toolbar OF cl_gui_alv_grid
              IMPORTING e_object e_interactive,
    To handle the buttons on the alv grid
         handle_user_command
           FOR EVENT user_command OF cl_gui_alv_grid
           IMPORTING e_ucomm.
    endclass.
    Now Implement these methods.
    CLASS lcl_event_receiver IMPLEMENTATION.
    To handle the toolbar on alv
      METHOD handle_toolbar.
       DATA ls_toolbar  TYPE stb_button.
        CLEAR gs_toolbar.
        MOVE 3 TO gs_toolbar-butn_type.
        APPEND gs_toolbar TO e_object->mt_toolbar.
        CLEAR gs_toolbar.
        PERFORM icon_create USING 'ICON_INSERT_ROW' gs_toolbar-icon.
        MOVE text-010 TO gs_toolbar-function.
        MOVE text-012 TO gs_toolbar-quickinfo.
        MOVE ' ' TO gs_toolbar-disabled.
        APPEND gs_toolbar TO e_object->mt_toolbar.
        CLEAR gs_toolbar.
        PERFORM icon_create USING 'ICON_DELETE_ROW' gs_toolbar-icon.
        MOVE text-011 TO gs_toolbar-function.
        MOVE text-013 TO gs_toolbar-quickinfo.
        MOVE ' ' TO gs_toolbar-disabled.
        APPEND gs_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.
       METHOD handle_user_command.
    In this form, check the function code(e_ucomm has the function code), based on that do the required action.
    as i said yesterday(i.e for appending a row, deleting a row, modifying a row)
        PERFORM user_command USING e_ucomm.
      ENDMETHOD
    endclass.
    Before calling the alv method, create a object of this class.
    DATA :
          gref_event_receiver  TYPE REF TO lcl_event_receiver,
          gv_tables_alv          TYPE REF TO cl_gui_alv_grid.
          CREATE OBJECT gref_event_receiver.
          SET HANDLER   gref_event_receiver->handle_user_command
                        FOR gv_tables_alv.
          SET HANDLER   gref_event_receiver->handle_toolbar
                        FOR gv_tables_alv.
    check this program for event handling, it is the similar way
    demo_abap_objects_events
    Hope u understood this.
    Regards,
    Prasant
    reward if helpful

  • How to create a georaster object?

    Hi,
    I type this codes to create a georaster object. but there is error msg.
    SDO_GEOR.createBlank(
    rasterType IN INTEGER,
    ultCoord IN SDO_NUMBER_ARRAY,
    dimSizes IN SDO_NUMBER_ARRAY,
    cellValue IN NUMBER,
    rasterDataTable IN VARCHAR2 DEFAULT NULL,
    rasterID IN NUMBER DEFAULT NULL
    ) RETURN SDO_GEORASTER;
    Error Message:
    Error starting at line 1 in command:
    SDO_GEOR.createBlank(
    Error report:
    Unknown Command
    Error starting at line 3 in command:
    rasterType IN INTEGER,
    Error report:
    Unknown Command
    Error starting at line 5 in command:
    ultCoord IN SDO_NUMBER_ARRAY,
    Error report:
    Unknown Command
    Error starting at line 7 in command:
    dimSizes IN SDO_NUMBER_ARRAY,
    Error report:
    Unknown Command
    Error starting at line 9 in command:
    cellValue IN NUMBER,
    Error report:
    Unknown Command
    Error starting at line 11 in command:
    rasterDataTable IN VARCHAR2 DEFAULT NULL,
    Error report:
    Unknown Command
    Error starting at line 13 in command:
    rasterID IN NUMBER DEFAULT NULL
    Error report:
    Unknown Command
    Error starting at line 15 in command:
    ) RETURN SDO_GEORASTER;
    Error report:
    Unknown Command
    Please advise me on how to create a georaster object as i am very new to the technology.
    Thanks and regards,
    Esther

    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14254/geor_intro.htm

  • How to create new layers in captivate?

    Hi,
    how to create new layers in captivate's timeline?
    Regards,
    krishnaraj

    Hi krishnaraj
    Sounds like you may be expecting Captivate to work
    identically to Flash. Sorry my friend, it doesn't work this way.
    For starters, notice that Captivate uses slides.
    Each slide has its own timeline. So what you see in the timeline
    area is not for the whole movie.
    As you add objects (Buttons, Click Boxes, Images, Rollover
    Areas, Etc.) the object is placed on the timeline and assumes what
    you are referring to as a layer. You then control which object is
    in front of another object by its relative position in the layer.
    This is called the "Stacking Order".
    Hopefully this helps... Rick

  • How to create new database on Oracle 10g

    Hi All,
    Can any one tell me how to create new database on oracle 10g.
    Thanks in Advance for your help.

    again some confusion here.....
    u said u need a new database in your first post and now you saying u need a new schema..
    one database has many schemas(users)..... ex: scott,sys,system are few of them...
    now it depends you need seperate database for test,dev environment - this is in the case u have many schemas under each database and many tables(objects) under each schema.
    OR
    You just need a separate schema (in same db) for test,dev environment...where in you will have multiple tables in each schema...U need to know the dba credentials of the db to create a new schema.
    ideally u need to have different database...You can create one with out sys/system(oracle users) password as these passwords are db dependent.
    what you need is access to the any machine where server is installed(can be the same mc where you have your dev db or a diff machine) and that will be the machine where your db will be installed (can do it through database configuration assistance),ofcourse you will need windows authentication for this.
    so you login to the same machine or access it from your machine using remote login.
    I hope that is clear.Hope i am not listing things that you already know..Just did it coz of confusion between db and schema
    Message was edited by:
    coolguy

  • How to create new starting conditions for a workflow of shopping cart

    Hi all,
    How to create new starting conditions for a workflow of shopping cart
    SATYA

    Excecute SWB_COND
    Creating New:
    Click on Create button. If you cannot see that it could be a authorization issue
    then Business Object:  BUS2121
    Double Click the event linkage for one step workflow
    Define the expressions, Check Consistency and click on Traansfer
    Start Condition is created. If it is not Active click on the Red Button to make it Active
    Editing Already existing:
    Click on Edit Button If you cannot see that it could be a authorization issue
    then select Business Object:  BUS2121
    Click on the condition part (White area) of the start condtion needing editing
    Change the expressions, Check Consistency) and click on Traansfer.If it is not Active click on the Red Button to make it Active

Maybe you are looking for

  • Installation Problem on Pentium4 with ORACLE 8.1.7 Client

    I tried to Install the ORACLE Client 8.1.7/8.1.6 on Pentium4 with NT platform. On inserting the CD it gave the first prompt and after Clicking the "INSTALL/DE-INSTALL PRODUCTS", system stops. Checking in the TaskManager helps us to know that 'setup.e

  • I HAVE A QUESTION ABOUT USING CASE STRUCTURE

    Can I compute a percentage using case structure? In the following query below, I have been able to use CASE STRUCTURE to add to a counter when days were between 0 and 30, or when days were between 31 and 60 or when days were between 61 and 90 or when

  • Anyone else having crash problems with mountain lion and parallels 8.0?

    Anyone else having crash problems running Mountain Lion and Parallels 8.0 ?

  • Missing movie menu on apple tv

    Hi :-) I am missing the "movie" list on my apple tv after it comes back from standby. The main menu only shows internet, computer, settings.... the movie menu is completly missing. After resetting apple tv to default the movie menu is back, but all m

  • Yoga 10´OTA Update Contacts FC

    Today I dowloaded Yoga 10 OTA KitKAt update. After rebooting it gives "Yhteystietojen hallinta on pysähdynyt" pop-up window. Its in finnish and in englis its translated something like this "Contacts application have stopped". How I can redownload upd