How to obtain JNIEnv pointer and jobject reference in arbitrary contexts?

Hi,
I need your hand. How to obtain JNIEnv pointer and jobject reference in arbitrary contexts? (See below source codes for details)
I made some tries according to JNI spec, but still failed to get it work. Could you please provide your solutions? Better show me some source codes.
Thank you very much !!!
#include <jni.h>
#include "MessageThread.h"
#include "MyServer.h"
// this is callback function called by the native C++ library
void processEvent(int progress)
   in this function, i want to get "env", "obj" ( HOW? ),
   then i can do below to invoke Java function "updateUI":
   cls = env->GetObjectClass(obj);
   mid = env->GetMethodID(cls, "updateUI", "(I)V");
   env->CallVoidMethod(obj, mid, progress); 
JNIEXPORT void JNICALL
Java_MessageThread_handleMessageQ(JNIEnv *env, jobject obj)
  MyServer* server = MTMServer::Instance();
  if (server != NULL)
    // must register a callback function before "QueryProgress"
    server->RegisterCallback(processEvent);
    // query message within a loop, and callback "processEvent" frequently
    server->QueryProgress();
  return; 
}

jschell, thanks for your suggestions.
And caching the second is definitely wrong. Arguments are passed as local references. The reference lifetime is only guaranteed for the lifetime of the method call.In my case, it just works, because my "callback" is only called before the "handleMessageQ" returns, which means it's within the lifetime of "jobject", etc.
Use GetEnv to get the environment.Could you please provide some sample codes?
Create a static java method which returns the object reference. In your callback call that method to get the reference that you want to work with. I didn't really understand. Could you please show me some sample codes?
Thanks a lot!

Similar Messages

  • How to obtain a Question and Answer DB from Solution manager.

    Dear Gurus,
    How to obtain a Question and Answer DB from Solution manager for HCM.
    Regards,
    Rajasekar.

    http://saphrexpert.blogspot.com/2008/12/questionairre-to-be-used-during.html
    Check this link
    this is not the answer to your question but it  will helpful

  • How to delete decimal point and adding leading zeros....

    Hi,
    I have one requirement in the report   i.e.
            <b>Present Value    :</b>  44567.98
            <b>Expected Value  :</b> 0000004456798
    In the present Value how will I remove that decimal point and how to add those six ing zeros. I tried with CONVERSION_EXIT....but it is not giving. Help me...
    Thanks in advance.
    Regards,
    Kumar.

    Hi,
    Use SPLIT and COMCATENATE fnctions.
    Eg:  split l_v at '.' into l_v1 l_v2
            concatenate l_v1 l_v2 into l_v.
    For adding leading zeros
    Use FM CONVERSION_EXIT_ALPHA_INPUT.
    Eg:
    data: tknum type vttk-tknum value '99156'.
    call function 'CONVERSION_EXIT_ALPHA_INPUT'
         exporting
              input  = tknum
         importing
              output = tknum.
    Sri
    Message was edited by:
            Sri Tayi

  • How to get vendor name and invoice reference details in asset register

    Hi Experts,
    My client requirement is he want to see Vendor name and invoice reference filed in asset register.
    Is there any standard reports relating this requirement.
    Kindly Provide valuable information relating to this issue.
    Regards
    Madhan

    Hi Madhan,
    Let me know the t.code which you are getting asset data.
    Thanks

  • How to obtain profit centers and cost centers for a particular GL account

    Hi Gurus
    Can you please suggest me a table or a function module to obtain profit centers and cost centers for a particular GL account.
    Thanks in advance for help!
    Regards
    Ankit

    Hi There, I have a simillar problem as above, however I would like a list of all G/L Accounts with profit centres and cost centres as well. Is this possible? Reason being that I have many unassigned cost centres and need to link them to profit centres.
    Is there also a mass processing list to see which G/L accounts dont have primary elements assigned?
    Regards,
    Edited by: Luke Saloojee on Jul 29, 2008 8:12 AM

  • How to obtain a list of subcontext names within a context?

    Hello, I'm just curious if anyone in here has overcome this issue. It'll be great if any of you can help me out a little.
    For example...
    1) Assume there is 2-3 subcontexts within a context, and 2-3 java objects that is also stored within that context.
    2) When you do a search with the returning object flag in search control to true, I'll run to an error when I hit a subcontext, because I created a loop that will store the object into a list by something like
    obj = sResult.getObject( ) ;
    This came to a conclusion for me that before I store any object, I should obtain a list of the subcontexts within the context, so that I'll not call the getObject( ) method when I get to a subcontext.
    Suggestion and advice is welcomed!
    Thanks for reading!

    Nevermind, problem solved! Thanks for reading... :)
    Problem:
    I am going through the NamingEnumeration list that gets returned when I call the search method, and within my loop, when I call the getObject( ) method, and if it is a subcontext, then I'll hit an exception which will stop my loop.
    Try
    Loop
    Catch
    Solution:
    Now, in this case, I can loop, then in my try block, I will store my object, if I get an exception, then I know it is a subcontext, and I'll continue on within my loop.
    Loop
    Try
    Catch
    Hope that other people will benefit from this.

  • How to obtain SPRuntime pointer?

    Hi,
    In Adobe Dialog Manager documentation there is such code snippet:
    SPErr error = kSPNoError;
    SPHostProcs *gHostProcs;
    error = sSPRuntime->GetRuntimeHostProcs(&gHostProcs);
    if (!error)
    gHostProcs->startupNotify(kSetMessage,
    (void*)"Initializing QuickDraw 3d", gHostProcs->hostData);
    What is the way from plugin code to obtain that sSPRuntime pointer?

    jschell, thanks for your suggestions.
    And caching the second is definitely wrong. Arguments are passed as local references. The reference lifetime is only guaranteed for the lifetime of the method call.In my case, it just works, because my "callback" is only called before the "handleMessageQ" returns, which means it's within the lifetime of "jobject", etc.
    Use GetEnv to get the environment.Could you please provide some sample codes?
    Create a static java method which returns the object reference. In your callback call that method to get the reference that you want to work with. I didn't really understand. Could you please show me some sample codes?
    Thanks a lot!

  • How to obtain mesh geometry and topology data?

    I am using JavaScript 3D engine for Adobe Acrobat.
    I am using the "Mesh" class.
    It seems that geometry and topology information is not available from "Mesh" class.
    Is it right?
    Can anybody to advise me a method for obtain geometry and topology information?
    P.S. Geometry = geometrical information about mesh, such as vertex coordinates. Topology = triangle connectivity.
    Thanks for any advise!

    We really need screen shots (*png format/NOT .bmp!) or attached code to see what might be the problem. There are an infinite number of mistakes that can be made (or nearly so), depending on how a program is written.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • How to obtain corner points of rotated rectangle?

    Am drawing a rectangle, then using an Affine Transform to rotate the angle. After rotating and drawing the rectangle, I need to obtain the 4 corner points of the rectangle. This is (psuedocode) for what I've tried:
    Rectangle r = new Rectangle (x, y, width, height);
    AffineTransform at = new AffineTransform();
    at.rotate (angleInDegrees*Math.PI/180);
    Shape s = at.createTransformedShape (r);
    PathIterator pi = s.getPathIterator(at);
    while (pi.isDone() == false)
    fetchCornerPoint (pi);
    pi.next();
    g2.draw(s);
    The shape is being correctly drawn on the screen, so I know the transofmr is working. But the path appears to contain the 4 corner points of the rectangle prior to rotation, not the 4 corner points after the rotation.
    It's got to be a "doh moment", but I can't see it.

    I notice you call getPathIterator on 's', which is already transformed. I have not verified this, but maybe you should call getPathIterator(at) on the original shape ('r')?

  • How do I earn points and level up?

    I am still stuck on level one, when others are at level TEN. How do I level up? Please help me. And when can I report a post?

    Reporting posts comes at level 2.  But do not abuse it, please.
    Answer questions, folowing terms of use (see ink below).
    The OP (original poster) decides who gets "Answered" and who gets "Helped".  Sometimes you disagree with that judgment, but such is life.
    You cannot ask for points, just hope they are given.
    Details of levels ... https://discussions.apple.com/static/apple/tutorial/reputation.html

  • Report Generation Toolkit (Word) : How to use correctly bookmark and cross-reference without "Error! Reference source not found"

    Hi,
    I try to generate a report using a template. In my template I use some cross-reference to refer to one bookmark. For exemple in the first page I created a bookmark for my name and in the header I created a cross-reference refer to my name. The problems is when I run my VI the bookmark actualise perfectly but the cross-reference refer to the bookmark can't actualise with the same value and generates an error : "Error! Reference source not found".
    Can somebody help me please!
    Nki
    Solved!
    Go to Solution.
    Attachments:
    01.jpg ‏72 KB

    Hi,
    When i create the word template, the bookmaks and the cross-reference referred to the bookmark update correctely. The problem is when I try to change the bookmark using "report generation from template vi" the bookmark change but not the cross-reference and the error generated is "Error! Reference source not found". 
    I make coople reasherch and i think they have no solution for this because : "if the text in a heading referred to in a cross-reference is revised, the cross-reference to the heading may no longer work" (http://office.microsoft.com/en-us/word-help/troubleshoot-cross-references-HP005189368.aspx).
    To "resolved" this problem I create an other bookmark in the template who have the same value white the principle bookmark.   
    I use Labview 2011 and Micosoft office 2010.

  • How to get current application and page references

    Hi,
    I have buttons (to print and download in PDF, CSV, XLS) on several pages... at the moment I am using following code to get them working...
    http://apex.oracle.com/pls/apex/f?p=31815:3:&SESSION.:PDF
    which means that on every page I need to put the reference in hard coding... is there a way to replace page number and application ID with a reference (similar to what I've done above to the session ID)... something like this
    http://apex.oracle.com/pls/apex/f?p=REF_APP_ID:REF_PAGE_ID:&SESSION.:PDF
    Thanks

    Hi,
    Use substitution strings. And you do not need write whole URL
    http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/concept.htm#sthref156
    f?p=&APP_ID.:&APP_PAGE_ID.:&SESSION.:PDFRegards,
    Jari

  • How to format power points and spreadsheets to be compatible with pcs?

    I just bought a macbook pro. Made a spreadshhet and a powerpoint to send to a coworker. My coworker coul not open it on work pc. I thought the compatability isses were resolved. How can I format to send to a pc?

    In Office 2011 in PowerPoint
      Create or open the document that you want to check.
      On the File menu, click Save As.
      Click Compatibility Report and if you receive a message that you have at least one compatibility issue, click OK to look at the issues. Otherwise, click OK to close the compatibility check.  If there are compatibility issues, the Compatibility Report pane opens.
      In the Compatibility Report pane, on the Check compatibility with pop-up menu, click the version of Office that the document might be opened in, and then do one of the following: 
    If you want to
    Do this
    Try to fix the Compatibility Report issue
    Under Results, click an issue, and then click Fix.
    Learn more about the Compatibility Report issue
    Under Results, click an issue, and then click Help.
    Ignore the Compatibility Report issue
    Under Results, click an issue, and then click Ignore.

  • URGENT: How to obtain workbook id and worksheet id

    Please let me know in which EUL tables workbook id and worksheet id of report is stored in discoverer.

    Workbook id is stored in EULx_DOCUMENTS as DOC_ID.
    but unfortunately you can't get the worksheet id as the whole workbook is stored as a single object (long raw) in this table.

  • How to obtain the integer and fractional parts of a number ?

    Good morning,
    given the value:
    5433.43567
    I'd like to know if there is a function such that
    f(5433.43567) = 5433
    and another such that
    f2(5433.43567) = 0.43567Without any rounding, truncation or other "special effects" ;). I can synthesize those functions using to_char, string manipulation and to_number but I'd like to make sure that I didn't miss a simpler way or, a combination of those functions that is really simple (the stuff I've come up with is hardly simple :( )
    Thank you for your help,
    John.

    440bx - 11gR2 wrote:
    Good morning BluShadow, Afternoon! :)
    select regexp_substr(.43567, '[^.]+', 1, 1) as whole_part
    ,regexp_replace(5433, '[^.]+\.(.*)$', '0.\1') as fract_part
    from dual;
    The result should be 0 (or blank).
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 5433.43567 as num from dual union all
      2             select 0.43567 from dual union all
      3             select 5433 from dual)
      4  select num
      5        ,regexp_substr(num, '^[^.]+') as whole_part_string
      6        ,regexp_substr(num, '\.[^.]+$') as fract_part_string
      7        ,trunc(num) as whole_part_number
      8        ,num-trunc(num) as fract_part_number
      9* from t
    SQL> /
           NUM WHOLE_PART_STRING                        FRACT_PART_STRING                        WHOLE_PART_NUMBER FRACT_PART_NUMBER
    5433.43567 5433                                     .43567                                             5433               .43567
        .43567                                          .43567                                                0               .43567
          5433 5433                                                                                        5433                    0
    SQL>Personally, I'd just stick with the number variants using trunc. Far simpler to use and you're still dealing with numbers.

Maybe you are looking for