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 8062975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:51:43+00:00 2026-06-05T10:51:43+00:00

I need to pass from Java List< List<MyPoint> > points; over jni to C++

  • 0

I need to pass from Java

List< List<MyPoint> > points;

over jni to C++ and convert to

std::vector< std::vector<MyPoint> >

Process this vectors and return

List< List<MyPoint> >
  1. How correct pass and return list of lists?
  2. How convert list of lists of objects in vector of vectors of objects and backward?
  • 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-05T10:51:46+00:00Added an answer on June 5, 2026 at 10:51 am

    I solved this problem with standard tools.

    1. Create in Java class as objects (O) container (C)
    2. Pass array of objects (O) from Java code to native part
    3. Create from array vector in C++ code
    4. Calculate new vectors
    5. Build array of containers (C) and insert into objects (O)
    6. Return array of containers (C)

    Code implement:

    On java part:

    1 – Create array from list of points

    On c++ part:

    2 – build input vector

    std::vector<CurvePoint> src_line;
    
    jclass java_points_cls = env->FindClass("myPointClass");
    jmethodID java_mid = env->GetMethodID(java_points_cls, "<init>", "(II)V");    
    jfieldID fidX = env->GetFieldID(java_points_cls, "x", "I");
    jfieldID fidY = env->GetFieldID(java_points_cls, "y", "I");
    
    int srcCount = env->GetArrayLength(srcLines);
    
    for (int i=0; i < srcCount; i++) 
    {
        jobject cur_pnt =  env->GetObjectArrayElement(srcLines, i); 
    
        LinePoint src_point;        
    
        src_point.x = env->GetIntField(cur_pnt, fidX); 
        src_point.y = env->GetIntField(cur_pnt, fidY);    
    
        src_line.push_back(src_point);
    }
    

    3 – calculation lines

    4 – build output array

    jclass java_line_cls = env->FindClass("myLinesClass");
    
    jmethodID java_line_add = env->GetMethodID(java_line_cls, "addPoint", "(II)V");  
    jmethodID java_line_init = env->GetMethodID(java_line_cls, "<init>", "()V");
    
    jobjectArray resLines = (jobjectArray) env->NewObjectArray(lines.size(),     java_line_cls, 0); 
    
    for(int i = 0; i < lines.size(); ++i)
    {
        jobject cur_line =  env->NewObject(java_line_cls, java_line_init);
        for(int j = 0; j < lines[i].size(); ++j)
            env->CallVoidMethod(cur_line, java_line_add, 
                                    lines[i][j].x,
                                    lines[i][j].y);
        env->SetObjectArrayElement(resLines, i, cur_line);
    }
    
    return resLines;
    

    Java part

    5 – Create list of lines from returned array

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

Sidebar

Related Questions

i need to pass a long list of Ids from one page to another,
For interoperability, I need to pass a Scala PartialFunction from Java code. For Function
I need to pass a variable from Admin.java file to index.jsp. I get the
I need to pass an url from asp.net load_page to flowplayer javascript function here:
I have a server script that I need to pass data to from the
I have an application in which I need to pass an array from C#
I need to pass a Infragistics ultrawebtree from a page to another. I used
I need to use Velocity from Java-code in a web-application (I use it as
I have to pass some strings from a java servlet to a php script.
I want to pass several parameters to this url and generate the map from

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.