Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8197373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:43:40+00:00 2026-06-07T05:43:40+00:00

Currently in my application I am using C++(core implementation) and java(services and presentation). Now

  • 0

Currently in my application I am using C++(core implementation) and java(services and presentation). Now in my C++ core I am getting an exception, which I am catching in JNI code and creating a throwable object of it, and throwing it to java layer. So that it can be further processed.

For catching exception on jni I am using following code,

catch (namespace::MyException& excep) {
    jclass ex = jenv->FindClass("namespace/MyException");
    jmethodID constructor;
    jthrowable object;
    jobject obj;
    if (ex)
    {
            constructor = jenv->GetMethodID(ex, "<init>", "(Ljava/lang/String;Ljava/lang/String;I;I)V");
            if(!constructor)
            {
                SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, (char*) excep.what());
                return $null;
            }

            jstring str = jenv->NewStringUTF(excep.what());
            jstring str2 = jenv->NewStringUTF(excep.GetStackTraceAsString());
            obj = jenv->NewObject(ex, constructor, str, str2,excep.GetCat(),excep.GetCate());

            object = static_cast<jthrowable>(obj);
            jenv->DeleteLocalRef(str);
            jenv->DeleteLocalRef(str2);
            jenv->Throw(object);
    }
    return $null;
}

The C++ signature for my MyException Class is

MyException(string str1, string str2, int cat1, int cat2);

But in my Jni code I am not able to get methodId For MyException CTOR.

Can any one tell me what could have gone wrong in JNI code. What I suspect is that There is some Problem in parameterList in GetMethodId().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:43:42+00:00Added an answer on June 7, 2026 at 5:43 am

    You should not have any semicolons between primitives in your signature. It should be like this:

    (Ljava/lang/String;Ljava/lang/String;II)V
    

    Notice the II, not I;I.


    Edit

    You can always run javap -s <package.name.ClassName> on your built classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which is currently using and storing data in Core Data.
Currently we have developed application using Java 6 based on windows 32bit(Dual core &
I'm currently migrating my sqllite application to using core data. When I created the
I am currently building an application using Tomcat, Spring and JAVA. I am using
I'm currently writing a billing application using EF 5 Code First, and I'm running
I'm currently developing an application based on no-sql (using raven db). The core aspect
Currently developing an application using the newest version of symfony, obtained through PEAR. This
I'm currently writing an application using Vala that requires me to send data over
Hello my friend is currently development an application using SOA Architecture, He sent me
Currently I'm building an application using latest Prism for Silverlight 4. I've a module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.