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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:47:46+00:00 2026-06-04T16:47:46+00:00

i have a native method with user defined datatypes(structure) as the parameters.How do i

  • 0

i have a native method with user defined datatypes(structure) as the parameters.How do i call this method from java using JNI?

  • 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-04T16:47:47+00:00Added an answer on June 4, 2026 at 4:47 pm

    If you have a method like this:

    int cFunction(mydatatype data) ...
    

    You cannot call it directly. You will need a layer of JNI to glue it together.


    So a JNI function is someting generated from your code:

    class JavaTest {
        public native int jMethod(int a);
    }
    

    Running javah on that class you would get a header file like this:

    JNIEXPORT jint JNICALL Java_Javatest_jMethod(JNIEnv*, jobject obj, jint a);
    

    Implementing that method to call cFunction(mydatatype):

    JNIEXPORT jint JNICALL Java_Javatest_jMethod(JNIEnv*, jobject obj, jint a) {
        mydatatype data;
        data.count = a;
        return (jint) cFunction(data);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some JNI code in a thread that calls from Java to C.
This is probably a multi-part question. Background: we have a native (c++) library that
I have a crash report from a user which i couldn't recreate same error
I have the following scenario- Pig version used 0.70 Sample HDFS directory structure: /user/training/test/20100810/<data
I am using BTrace 1.2 and followed user guide from BTrace website . I
I have PHPMyAdmin connecting to a remote MySQL server, using those parameters: $cfg['blowfish_secret'] =
I have a simple Java program (using JTOpen) to connect to an iSeries and
I have Class in java called XMLDOMDocument this class have some methods CreateXML ,
see i have mainActivity which calls tempActivity Now inside tempActivity i call some native
I have a Booking controller class (generated, NetBeans), having update method, called from JSF

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.