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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:40:53+00:00 2026-05-29T08:40:53+00:00

How do two values I pass into my JNI tossed down to C then

  • 0

How do two values I pass into my JNI tossed down to C then C does its changes and updates the values. How do I get those two values(maxPower, index) and see then in Java? They always come back as zero.

JNIEXPORT jdouble JNICALL Java_com_TV (
     JNIEnv* env, jobject obj, jdouble maxPower, jint index)
{
    jdouble result = 0;

    result = Feature_TV(2, &maxPower, &index );

    return result;
}

// here is the c function it calls it actually does more than this but for
// demo it should return result 60 and maxPower and index should be -5.0 and -2..

double Feature_TV(double * maxPwr, int * maxPwrIdx ) {

    *maxPwr = -5.0;
    *maxPwrIdx = -2;

    /// do something 

     return 60;
}
  • 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-29T08:40:54+00:00Added an answer on May 29, 2026 at 8:40 am

    There is no way to modify the variables that are passed to Java_com_TV because C is pass-by-value, just like Java. When you call Feature_TV and pass the addresses of maxPower and index, the addresses are of the local variables in Java_com_TV and no outside effect can be seen.

    To do what you want to do you could either

    1. make com.TV accept an object that has maxPower and index as fields, and modify the fields from JNI, or
    2. make it return such an object, and create the object and set the fields in JNI.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to code a way to pass the values from two spinners into
Is it possible to get form field values into an array? Example: <?php array('one',
In an ajax call (for a game) that tries to pass two values in
I want to pass two values to another activity can I do this with
I have three values (foo,bar,bad) and based on which one I pass into a
I'm trying to pass multiple values from PHP into my javascript function. The function
im trying to pass two parameters to a function, i being an int value
I am setting two values based on two different conditions inside for each. Is
I need to return two values at a time, so I have: class IterableObject(object):
I'm trying to SELECT two values in one statement instead of two statements. The

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.