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

  • Home
  • SEARCH
  • 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 6707197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:36:39+00:00 2026-05-26T07:36:39+00:00

I am using Java native function – public native ArrayList<String> parseXML(); In C++ my

  • 0

I am using Java native function –

public native ArrayList<String> parseXML();

In C++ my native function –

vector<string> resultList;

JNIEXPORT jobject JNICALL Java_Sample1_parseXML
(JNIEnv *env, jobject obj){
   // logic
   return resultList;   // here getting error
}

My problem is that how to convert resultList (vector type) to jobject type?

  • 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-05-26T07:36:40+00:00Added an answer on May 26, 2026 at 7:36 am

    You would have to create a wrapper for the ArrayList in C++. Something like:

    vector <char*> vec;
    
    jclass clazz = (*env).FindClass("java/util/ArrayList");
    jobject obj = (*env).NewObject(clazz, (*env).GetMethodID(clazz, "<init>", "()V"));
    
    for (int n=0;n<vec.size();n++)
    {
       char* str = (char*) static_cast<char*>(vec[n]);
    
       jstring _str = (*env).NewStringUTF(str);
    
       (*env).CallVoidMethod(object, (*env).GetMethodID(clazz, "add", "(java/lang/Object)V"), _str);
    
    }
    
    return obj; 
    

    for further information see:

    http://download.oracle.com/javase/1.4.2/docs/guide/jni/spec/functions.html

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

Sidebar

Related Questions

I am using native function in my java class. I have written C++ function
Using Java (1.6) I want to split an input string that has components of
I am using Java back end for creating an XML string which is passed
The setup I have is I'm using a Java application to call native C-code
I am using Java native serialization along with a dynamic proxy to save the
I generated a very simple runnable jar file using Eclipse's Export-->Java-->Runnable Jar File function.
I am trying to run the following C function from Java using JNA, but
Is it possible to call a native CPP function using JNI which takes generic
To implement a callback function from the native code to Java code, I have
Is possibility in java without using native functions to send datagrams ?

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.