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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:29:56+00:00 2026-06-18T11:29:56+00:00

How to deliver a string array? I post the code: xx.cpp JNIEXPORT jstring JNICALL

  • 0

How to deliver a string array?

I post the code:

xx.cpp

JNIEXPORT jstring JNICALL Hello_Native(JNIEnv *env, jobject obj,jstring string)
{
    const char *str = env->GetStringUTFChars(string, 0);
    return env->NewStringUTF( "Hello from JNI !");
}
static JNINativeMethod gMethods[] = {
   {"JniHello",const_cast<char*>("(Ljava/lang/jsting)Ljava/lang/jsting;"),(void*)Hello_Native}

xx.java

public native static String JniHello(String text);

System always prompt it has the problem when declare JniHello in gMethods and the parameter is not right.

  • 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-18T11:29:57+00:00Added an answer on June 18, 2026 at 11:29 am
    1. stop using wrong manual names for JNICALL functions. javah will generate it for you correctly. If your Java name is JniHello in class MyHello and your package is com.hello , JNICALL function must be Java_com_hello_MyHello_JniHello. It can’t be Hello_Native, you have made it up.
    2. then of course this correct function name must be used in the last member of JNINativeMethod struct
    3. there is no such class as java/lang/jsting. There is not even a java/lang/jstring if i add the missing r for you. You are asked for the JAVA signature, not JNI. So it must be java/lang/String.
    4. ADDED (thanks @EJP): stop using wrong manual strings for JNI signatures and use the output of javap -s instead

    Your code has one more problem: when used GetStringUTFChars, you must also call `ReleaseStringUTFChars’ before returning, otherwise you have a leak. But you will find this yourself sooner or later.

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

Sidebar

Related Questions

i have an ashx file that requires some query-string values to deliver appropriate images.
I have an arrays.xml file containing quite a few string-array elements for use with
Can anybody please tell me why the string comparisons below deliver these results? >>1040<=12000
I have the following code: #include <iostream> #include <string> void main() { std::string str;
I'm serving a JSON API for posts, where I want to deliver the post
I have a struct like this: struct VrtxPros{ long idx; std::vector<std::string> pros; VrtxPros(const long&
I'm using the following code to generate a random string: <?php function random_string( )
Google Maps API delivers me a string which contains the German letters: ö, ä
I deliver an application via an RPM. What I need to do is if
I'd like to deliver special versions of my django site for different (mobile-)browser. What

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.