Getting Error with the C++ code

I have a function in C++ which accepts a "jstring". And if i write the below line of code it gives me error.
jsprData -> is the jstring INPUT
char sprData = (env)->GetStringUTFChars(env, jsprData, 0);
But the same thing if i write in a "C Code" and build a DLL then it is working fine.
Why so ? Is there any different way to write a code to convert "jstring" to "char *" in C++ ?
Please do reply me.
Thanks in advance.
Patro

When you are using JNI from inside C++ use the wrappers such as JNIEnv, JavaVM instead of the C style calls. I wrote win32 dlls using the invocation API from C++ code and everything gets compiled without a hitch.
Here is a code example method that returns Java exceptions as CString objects:
CYourClassName::GetJavaException(jthrowable exObject)
    CString csExMessage;
    if ( exObject != NULL )
        mp_Env->ExceptionDescribe();
        jclass cls = mp_Env->FindClass ("java/lang/Throwable"); // check for cls to be NULL
        jmethodID method = mp_Env->GetMethodID ( cls,"toString", "()Ljava/lang/String;");
        jstring exMsg = (jstring) mp_Env->CallObjectMethod ( exObject, method ); // Check for NULL
        const char* ps = mp_Env->GetStringUTFChars ( exMsg, NULL);
        csExMessage.Format( "%s\n", ps );
        mp_Env->ReleaseStringUTFChars ( exMsg, ps );
    return csExMessage;
And in your .h file declare a member variable as:
    JNIEnv* mp_Env;
Also, do not forget to initialize mp_Env properly at the beginning. You could use something like this:
    jint ret = JNI_CreateJavaVM(&mp_Jvm, (void **)&mp_Env, &vm_args);
This code compiles and runs.
Hope this helps.
-- Avijit

Similar Messages

  • Error with the T-Code HREIC

    Hi All,
    We are implementing EIC and when I am accessing this T-Code.I am getting this error
    The error occurred on the application server XYZ(Our Server name) and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was: Method: IF_HTTP_CLIENTSEND of program CL_HTTP_CLIENT================CP Method: CREATE_SESSION of program CL_SAM_BSP_SESSION_LAUNCHER===CP Method: START_WORKER_SESSION of program CL_ICWC_SESSION_REGISTRY======CP Method: ONCREATE of program CLO23UTXK1DHIM8WX0QZD2TBW2KZ9CP Method: %_ONCREATE of program CL_O23UTXK1DHIM8WX0QZD2TBW2KZ9CP Method: DO_INIT of program CL_BSP_PAGE===================CP Method: GET_PAGE_CONTEXT_CURRENT of program CL_BSP_CONTEXT================CP Method: ON_REQUEST_ENTER of program CL_BSP_RUNTIME================CP Method: ON_REQUEST of program CL_BSP_RUNTIME================CP Method: IF_HTTP_EXTENSIONHANDLE_REQUEST of program CL_HTTP_EXT_BSP===============CP
    Kindly request your help on the same.
    Thanks
    Swati

    Hi Swati,
    It seems this error would come if there is some configuration issues. The detailed explanation and the same error is given in this thread:
    CREATE_SESSION of programCL_SAM_BSP_SESSION_LAUNCHER "COMMUNICATION ERROR".
    If this doesnot solve your issue then please try to post in this forums for faster response. As mark mentioned this is the wrong forum for this issue.
    Business Server Pages (BSP)
    Regards,
    ---Satish

  • I BOUGHT LIGHTROOM 5 IN LAREDO TX AND I TRIED TO GET IN MONTERREY MEXICO THE SERIAL NUMBER WITH THE REDEMPTION CODE BUT APPEARS AN ERROR. MY PC IS WINDOWS 8. COULD SOMEBODY HELP ME?

    I BOUGHT LIGHTROOM 5 IN BEST BUY LAREDO TX AND I TRIED TO GET IN MONTERREY MEXICO THE SERIAL NUMER WITH THE REDEMPTION CODE FROM THE BOX, BUT APPEARS AN ERROR. MY PC IS WINDOWS 8, COULD SOMEBODY HELP ME??

    I don't know that you can purchase Adobe software in the US for installing and using outside of the US.
    Redemption Code Help
    http://helpx.adobe.com/x-productkb/global/redemption-code-help.html
    Serial number and activation chat support (non-CC)
    http://helpx.adobe.com/x-productkb/global/service1.html ( http://adobe.ly/1aYjbSC )

  • Getting Error In the Routine - While writing Code for the Cross Reference.

    Hi,
    Getting Error In the Start Routine - While writing Code for the Cross Reference from the Text table ( /BIC/TZMDES with Fields /BIC/ZMDES(Key),TXTSH ) Getting Error as [ E:Field "ZMDES" unknown ].
    Transformation : IOBJ ZPRJ3(Source) -> IOBJ ZPRJC ( Target ).
    The Source  Fields are: 0logsys(Key),zprj3(Key),ZDOM3.
    The Target Fields are : 0logsys(Key),zprjc(Key),ZDOM3, UID.
    Here i am trying to Update the target Field UID by Comparing the Source Field [ zprj3(Key)] with the Text table ( /BIC/TZMDES ) and update the UID.
    The Code is as below:
    Global Declarations in the Start Routine:
    Types: begin of itabtype,
            ZMDES type /BIC/TZMDES-/BIC/ZMDES,
            TXT type /BIC/TZMDES-TXTSH,
             end of itabtype.
    data : itab type standard table of itabtype
    with key ZMDES,
    wa_itab like line of itab.
    Routine Code :
    select * from /BIC/TZMDES into corresponding fields of table itab for
    all entries in SOURCE_PACKAGE
    where ZMDES = SOURCE_PACKAGE-/BIC/ZPRJ3.
    READ TABLE itab INTO wa_itab
    WITH KEY ZMDES = SOURCE_PACKAGE-/BIC/ZPRJ3
    BINARY SEARCH.
    IF SY-SUBRC = 0.
    RESULT = wa_itab.
    CLEAR wa_itab.
    The tys_SC_1 structure is :
    BEGIN OF tys_SC_1,
         InfoObject: 0LOGSYS.
            LOGSYS           TYPE RSDLOGSYS,
         InfoObject: ZPRJ3.
            /BIC/ZPRJ3           TYPE /BIC/OIZPRJ3,
         InfoObject: ZDOM3.
            /BIC/ZDOM3           TYPE /BIC/OIZDOM3,
         Field: RECORD.
            RECORD           TYPE RSARECORD,
          END   OF tys_SC_1.
        TYPES:
          tyt_SC_1        TYPE STANDARD TABLE OF tys_SC_1
                            WITH NON-UNIQUE DEFAULT KEY.
    Please suggest with your valuable inputs.
    Thanks in Advance

    I have split the code in two.. one for start routine.. other for field routine.. hope this helps
    Types: begin of itabtype,
    ZMDES type /BIC/TZMDES-/BIC/ZMDES,
    TXT type /BIC/TZMDES-TXTSH,
    end of itabtype.
    data : itab type standard table of itabtype
    with key ZMDES,
    wa_itab like line of itab.
    Start routine
    select * from /BIC/TZMDES into corresponding fields of table itab for
    all entries in SOURCE_PACKAGE
    where ZMDES = SOURCE_PACKAGE-/BIC/ZPRJ3.
    Sort itab.
    field routine
    CLEAR wa_itab.
    READ TABLE itab INTO wa_itab
    WITH KEY ZMDES = SOURCE_FIELD-/BIC/ZPRJ3
    BINARY SEARCH.
    IF SY-SUBRC = 0.
    RESULT = wa_itab-<field name>

  • I receive an error message whenever I text recently entered contacts. It says the number is invalid. I have tried entering the number with the area code and without the area code.

    I receive an error message whenever I try to send text messages to new contacts. It says the number is invalid and to enter a 10 digit number. I have tried entering the phone number with the area code and without the area code. Any ideas?

    Same problem here. I've deleted the contact and had them text me, but when I try to text them back I get the same invalid number message! So frustrating! Please help!

  • ERROR - the ProtectKeyWithTPMAndPIN Method failed with the exit code: 8031005B

    Hello
    I am using the EnableBitlocker.vbs script to automatically assign the TPM and start the encryption. I am running it from an elevated command prompt. Here is are the arguments I am running with
    cscript EnableBitLocker.vbs /on:tp
    /l:c:\bitlockerlog.log /promptuser /ro:"MBAM" on
    All is well and it prompts the user for a PIN but then it fails.
    Here is the full log file. I haven't been able to find any info on the error code in the subject.
    Script processing started  02/07/2014       14:43:27
    Proper number of command line arguments passed to the script
    ---------------Executing with the following arguments------------------
    Enable parameters: tp
    Logging location: c:\bitlockerlog.log
    Create recovery key: No recovery key use specified
    Encryption method: 3
    Create SMS status MIF's: No SMS status MIF's will be created
    Reset TPM ownership: 1
    User prompting: 1
    Connection succeeded to MicrosoftTPM
    Successfully retrieved a TPM instance from the Win32_TPM provider class
    TPM found in the following state:
    Enabled - True
    Activated - True
    Owned - True
    Connection succeeded to MicrosoftVolumeEncryption
    TPM is in a ready state to enable BitLocker.
    Change TPM owner password specified on the command line.
    Random TPM owner password is: ;&K:)BU65|c7_v2n
    Completed converting old owner password to owner authorization:  0
    Completed converting owner password to owner authorization:  0
    Starting to change owner authorization process on the TPM
    ERROR - Failed to change owner authorization on the TPM with the following exit code:  80280001
    Successfully connected to WMI StdRegProv
    Checking if Group Policy encryption method is set...
    Found EncryptionMethod with value: 4
    Found EncryptionMethod policy registry key ignoring any /em options on command line
    Found ActiveDirectoryBackup with value: 1
    Found RequireActiveDirectoryBackup with value: 1
    Determined client Group Policy configured to require AD escrow of recovery password
    EncryptableVolumes count is: 1
    The EncryptableVolume(s) found: \\?\Volume{ad6db324-01dd-11e4-8272-806e6f6e6963}\
    EncryptableVolume used for encryption is: C:
    The volume has a protection status of: 0
    BitLocker Protection is Off
    Get conversion status is: 0
    The volume has a status of fully decrypted
    The following user is logged on: MGMT\80151318-sys
    Attempting to enable BitLocker TPM + Pin
    ERROR - the ProtectKeyWithTPMAndPIN Method failed with the exit code:  8031005B
    Script ended  02/07/2014       14:43:51
    Any and all help would be appreciated. This has worked before on a different laptop.
    Thanks

    Hi,
    This error indicates that the group policy isn't set correctly, when configure the group policy at teh server side, you should notice that only one of the additional authentication can be required at start up , otherwise a policy occurs, the notice can be
    found just like below:
    and after test, the error indeed occurs, just like the screen below:
    So, I suggest to check the group policy for bitlocker settings, you can only choose one start up authentication method.
    Regards
    Wade Liu
    TechNet Community Support

  • When trying to connect to Airplay speakers I get error message "The  network connection timed out" although some sort of connection is made as the speaker is turned on.  Same thing with Apple TV.  Is the distance from my speaker/ TV the problem?

    When trying to connect from iTunes to Airplay speakers I get error message “The  network connection timed out” although some sort of connection is made as the speaker is turned on.  Same thing with Apple TV.  Is the distance between my PC and the speaker or the AppleTV the problem?

    Hi whitwick,
    If you are having issues with your network connection when attempting to use AirPlay, you may want to use the steps in this article to troubleshoot -
    iTunes: Troubleshooting AirPlay and AirPlay Mirroring
    http://support.apple.com/kb/TS5209
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • I am trying to activate new itunes card. I am getting error message: The code you have entered has not been properly activated. Does this mean the store did something wrong or me?

    I am trying to activate new itunes card. I am getting error message: The code you have entered has not been properly activated. Does this mean the store did something wrong or me?

    Yes, the store didn't properly activate the card. If the store is nearly then you could try going back and asking them to do so, if it isn't (or if they can't/won't help) then try contacting iTunes Support (you will probably need to give them images of the front and back of the card, and possibly its receipt) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then iTunes Cards And Codes

  • Ical won't sync with yahoo calendar. Get error....There was an unexpected error with the request (domain CalDAVErrorDomain / error 1 / description 'The collection at "/dav/xyx/Inbox/" is not an inbox.').

    Hello, I get the below error when I start iCal and it tries to sync with my Yahoo Calendar. Any thoughts?
    There was an unexpected error with the request (domain CalDAVErrorDomain / error 1 / description 'The collection at "/dav/xyx/Inbox/" is not an inbox.').

    I am having same problem - I've added events to Ical and it's not updating in my Yahoo calendar. Getting this message: There was an unexpected error with the request (domain CalDAVErrorDomain / error 1 / description 'The collection at "/dav/mcarthur_c/Inbox/" is not an inbox.').

  • Help, I get error 13019 when trying to sync my 5th generation ipod. I see others have had this error with the touch, but this is not the touch. What can be done?

    Help, I get error 13019 when trying to sync my 5th generation ipod. I see others have had this error with the touch, but this is not the touch. Does anyone have any ideas what can be done?

    follow the steps in this article first
    =http://support.apple.com/kb/HT1451
    after that restore your ipod and resync it
    hope this helps:)

  • What is a user parameter list in iMovie? I am trying to sent the movie from imovie to idvd and I keep getting an error with the user parameter list. Help?

    What is a user parameter list in iMovie? I am trying to sent the movie from imovie to idvd and I keep getting an error with the user parameter list. Help?

    Can you give more details?   What exactly is the entire error message text?  there should be an error number too.   Are you trying to finalize this to an external disk?

  • Trying to burn CD but keep getting error message "The attempt to burn a disc failed. The burn failed because of a medium write error. Tried different speeds with no luck

    trying to burn CD but keep getting error message "The attempt to burn a disc failed. The burn failed because of a medium write error. Tried different speeds with no luck

    The burn failed because of a medium write error. Tried different speeds with no luck
    Then try to use a different brand of DVD or at least a different batch of DVD. The disk may be defective.

  • I purchased the TV FRIENDS in HD on iTunes (the iTunes store stated with every HD purchase you get the SD version as well) and want to download on my I Pod Classic and get error message the I POD can play this video.  How do I download?

    I purchased the TV FRIENDS in HD on iTunes (the iTunes store stated with every HD purchase you get the SD version as well) and want to download on my I Pod Classic and get error message the I POD can not play this video.  How do I download?

    I see there's no answer.
    This issue has ****** me off for a long time, and I am fed the **** up with it.
    I DO NOT WANT TO DOWNLOAD the Movies and TV shows to every *^&%^$%# Apple device, ONLY the MUSIC!!!
    COme on Apple!!!  FIx this!!!

  • Getting Communication error with the external tax system(VERTEX_MS0018)

    Hi All,
    I am a new SAP HCM self learner. I am practicing it on company's sandbox system. When I am trying to create a company and saving the address, it is returning Communication error with the external tax system(VERTEX_MS0018). I have already tried to solve is issue by going thru previous related to same issue like
    Communication error with the external tax system (VERTEX_MS0018) ...Urgent
    but coudn't solve the issue.
    Please help. Is this issue coming as I am using a training environment? any alternate approach?

    Hi Ravi,
    To disable the connection to Vertex:
    Goto tcode  SPRO > Cross Application Components > Transaction Tax Engine >
    Technical Settings> Define External Tax System
    Here an RFC would be defined. Remove it and try again.
    Also in SPRO > Cross Application Components > Tax Determination based on Jurisdiction Codes > External Tax Jurisdiction > Activate External Tax Jurisdiction.
    Remove the entry 'V' here.
    Regards,
    Srikishan

  • Error in the following code

    Hi
    If anyone can let me know why there is a problem with the following code. I get the following errors:
    ')' or ',' expected

    Sorry I did add in but it did not post....Anyway code below the erroe line are in bold. Line: 22,23 & 24.
    function scaleMovieClip(movieclip, seconds, startAtX, endAtX, startAtY, endAtY, trans)
        new mx.transitions.Tween(movieclip, "_yscale", trans, startAtY, endAtY, seconds, true);
        var _loc2 = new mx.transitions.Tween(movieclip, "_xscale", trans, startAtX, endAtX, seconds, true);
    } // End of the function
    function setPage()
        btnN = ["b" + prod];
        page = btnN;
        pageT.text = page;
        ptest.text = mypage;
        var mcTween = new mx.transitions.Tween(main, "_alpha", mx.transitions.easing.Strong.easeOut, 100, 0, 1.000000E-001, true);
        mcTween.onMotionFinished = function (ev)
            main.gotoAndStop(page);
            var _loc1 = new mx.transitions.Tween(main, "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 3, true);
        for (i = 0; i < prodArray.length; i++)
            bNum = i + 1;
           eval("["b" + bNum]")._xscale = 100;
            eval("["b" + bNum]")._yscale = 100;
            eval("["b" + bNum]").enabled = true;
        } // end of for
        eval("[page]").swapDepths(_root.getNextHighestDepth());
        quote1.removeMovieClip();
        eval("[page]").enabled = false;
        eval("[page]")._xscale = 120;
        eval("[page]")._yscale = 120;
    } // End of the function
    stop();
    prodArray = new Array("CFL Change-Over", "Showerheads", "Insulation", "Solar PV", "Solar Hot Water", "Tank to Toilet", "Heat Pumps", "Misc Hot Water");
    b1.onRollOver = b2.onRollOver = b3.onRollOver = b4.onRollOver = b5.onRollOver = b6.onRollOver = b7.onRollOver = b8.onRollOver = function ()
        scaleMovieClip(this, 1, 100, 120, 100, 120, mx.transitions.easing.Strong.easeOut);
        attachMovie("quote", "quote1", _root.getNextHighestDepth());
        quote1._x = -300;
        quote1._x = _xmouse + 10;
        quote1._y = _ymouse + 35;
        trace (_xmouse);
        if (_xmouse <= 130)
            quote1.gotoAndStop(2);
            quote1._x = _xmouse;
            quote1._y = _ymouse + 35;
        } // end if
        if (_xmouse >= 790)
            quote1.gotoAndStop(3);
            quote1._x = _xmouse + 10;
            quote1._y = _ymouse + 35;
        } // end if
        quote1.startDrag(lockcenter);
        btnN = this._name;
        item = btnN.substr(btnN.length - 1, btnN.length) - 1;
        myMsg = prodArray[item];
        quote1.msg = myMsg;
    b1.onRollOut = b2.onRollOut = b3.onRollOut = b4.onRollOut = b5.onRollOut = b6.onRollOut = b7.onRollOut = b8.onRollOut = function ()
        scaleMovieClip(this, 1, 120, 100, 120, 100, mx.transitions.easing.Strong.easeOut);
        quote1.removeMovieClip();
    b1.onRelease = b2.onRelease = b3.onRelease = b4.onRelease = b5.onRelease = b6.onRelease = b7.onRelease = b8.onRelease = function ()
        btnN = this._name;
        item = btnN.substr(btnN.length - 1, btnN.length) - 1;
        page = btnN;
        var mcTween = new mx.transitions.Tween(main, "_alpha", mx.transitions.easing.Strong.easeOut, 100, 0, 1.000000E-001, true);
        mcTween.onMotionFinished = function (ev)
            main.gotoAndStop(page);
            var _loc1 = new mx.transitions.Tween(main, "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 3, true);
        for (i = 0; i < prodArray.length; i++)
            bNum = i + 1;
            eval("["b" + bNum]")._xscale = 100;
            eval("["b" + bNum]")._yscale = 100;
            eval("["b" + bNum]").enabled = true;
        } // end of for
        this.swapDepths(_root.getNextHighestDepth());
        quote1.removeMovieClip();
        this.enabled = false;
        this._xscale = 120;
        this._yscale = 120;
    if (prod != "" || prod != null)
        prodTxt.text = prod;
        setPage();
    } // end if

Maybe you are looking for

  • List view component not being ordered

    I am using the list view component to represent my table data. for creating a new row, i use a popup which has a separate taskflow in which i create a new row. Now i need to refresh the list view component after this new row is created. I am doing th

  • How many Multi-Touch points can an iPhone/iPod touch have at the same time?

    How many Multi-Touch points can an iPhone/iPod touch/iPad have at the same time? I am curious as IIRC (but forgot where the article is on the Internet), if a touch surface is wanted to be able to detect more than 1 touch point at the same time, then

  • Changing file classification after importing

    I've got loads of CDs that contain spoken word and radio plays. When I imported them, the contents were automatically classified as individual songs and put in my Music library. Any way to have them reclassified as Audiobooks? I'd also like to have i

  • Problem in creating MessageMapping

    Hi Experts, I am working on a senario while creating Message Mapping system hanged,i have not saved it and i have to start IR again.when iam doing the Magain its giving problem while creating Message Mapping currently USER(me) editing it,but iam not

  • E-mail Issue NEED HELP

    Hello, I have a customer at Santa Clara University who wants to change from a Mac to a PC go figure! He is currently using Apple Mail and wants to export his e-mail addresses to GroupWise (Novell) on the PC. Can you tell me what he would need to do i