7 Replies - 909 Views - Last Post: 10 February 2013 - 08:37 PM Rate Topic: -----

#1 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

Passing c++ arrays to java jni

Posted 09 February 2013 - 11:14 AM

Ok, i am doing a java jni project, and i am trying to pass a string array from c++ to java. How is this done, i cannot figure out how to do it.
Is This A Good Question/Topic? 0
  • +

Replies To: Passing c++ arrays to java jni

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Passing c++ arrays to java jni

Posted 09 February 2013 - 01:16 PM

Can you show what you have attempted in terms of code?
Was This Post Helpful? 0
  • +
  • -

#3 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

Re: Passing c++ arrays to java jni

Posted 09 February 2013 - 01:28 PM

I haven't attempted anything besides directly passing the array on which didnt compile, because i don't know where to start.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Passing c++ arrays to java jni

Posted 09 February 2013 - 01:43 PM

So can you post that code?
Was This Post Helpful? 0
  • +
  • -

#5 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

Re: Passing c++ arrays to java jni

Posted 09 February 2013 - 03:37 PM

JNIEXPORT jobjectArray JNICALL Java_osjal_Battery_DeviceName(JNIEnv *env, jclass)
{
init1();
init2();
init3();
return DeviceName;
}


where devicename is a string array

This post has been edited by popgalop: 09 February 2013 - 03:37 PM

Was This Post Helpful? 0
  • +
  • -

#6 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Passing c++ arrays to java jni

Posted 09 February 2013 - 04:47 PM

I've just had a look at the Java Native Interface, and your code looks incomplete. I've never used JNI and I'm not going to take the time learning it.

You need to put a lot more effort in with learning how to use the JNI properly.
Was This Post Helpful? 0
  • +
  • -

#7 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

Re: Passing c++ arrays to java jni

Posted 10 February 2013 - 06:35 AM

ive done a lot of research i just dont know how to do arrays i can do anything else
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Passing c++ arrays to java jni

Posted 10 February 2013 - 08:37 PM

would be a lot easier to have Java to fetch that array fronm C++ if your design allow you to do so and use that alternative
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1