Skip to content

Instantly share code, notes, and snippets.

@I82Much
Created September 20, 2010 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save I82Much/588374 to your computer and use it in GitHub Desktop.
Save I82Much/588374 to your computer and use it in GitHub Desktop.
#include <jni.h>
#include "Translator.h"
#include <stdio.h>
extern "C" {
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
printf("We're loaded by the OS!\n");
return JNI_VERSION_1_4;
}
/*
* Class: TranslatorWrapper
* Method: fromBinary
* Signature: ([B)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_example_hellojni_HelloJni_fromBinary
(JNIEnv * env, jobject, jbyteArray) {
Translator * x = new Translator();
unsigned char chars[] = {1,2,3};
return env->NewStringUTF("HI");
}
/*
* Class: TranslatorWrapper
* Method: fromXML
* Signature: (Ljava/lang/String;)[B
*/
JNIEXPORT jbyteArray JNICALL Java_com_example_hellojni_HelloJni_fromXML
(JNIEnv * env, jobject, jstring) {
int numElems = 10;
jbyteArray result = env->NewByteArray(numElems);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment