• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

convert jbyteArray into jString ?

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i have to convert a jbyteArray into jString
my java prog is ---JniEx1.java

class JniEx1{

private native String getMessage(byte[] b,int i);
public static void main(String args[]) {

String s="Hello World";
byte[] b=s.getBytes();

JniEx1 je1 = new JniEx1();
String msg = je1.getMessage(b,60);
System.out.println("User typed: " + msg);
}
static {
System.loadLibrary("Prompt");
}
}



generated method signature in JniEx1.h is

JNIEXPORT jstring JNICALL Java_JniEx1_getMessage
(JNIEnv *, jobject, jbyteArray, jint);




now in c file ------

#include <jni.h>
#include <stdio.h>
#include "JniEx1.h"

JNIEXPORT jstring JNICALL Java_JniEx1_getMessage(JNIEnv *env, jobject obj,jbyteArray jbr, jint ji)
{

.............................................................................................................
........................................................................................................



}




What i will write in the .... area to covert jbyteArray jbr into some Jstring variable ?

 
Abhra Kar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
waiting for help
please response

Thanks in advance
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at the JNI tutorial?
 
Abhra Kar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I have solve the problem
I have seen this tutorial earlier, I will read it in details later .
 
Get me the mayor's office! I need to tell her about this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic