From 06b13987348dcb369f71efc46cca1228f11e3e6c Mon Sep 17 00:00:00 2001 From: GuilhermeWerner <26710260+GuilhermeWerner@users.noreply.github.com> Date: Fri, 7 May 2021 08:44:00 -0300 Subject: [PATCH] Add JNI Sample --- Source/Library.c | 12 ++++++++++++ Source/Library.h | 13 +++++++++++++ Source/TribuFu.java | 15 +++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 Source/Library.c create mode 100644 Source/Library.h create mode 100644 Source/TribuFu.java diff --git a/Source/Library.c b/Source/Library.c new file mode 100644 index 0000000..2f736b2 --- /dev/null +++ b/Source/Library.c @@ -0,0 +1,12 @@ +// Copyright (c) TribuFu. All Rights Reserved + +#include +#include "TribuFu.h" +#include "Library.h" + +JNIEXPORT jstring JNICALL Java_tribufu_TribuFu_Hello(JNIEnv *, jobject, jstring) +{ + char *result = Hello("C"); + + return result; +} diff --git a/Source/Library.h b/Source/Library.h new file mode 100644 index 0000000..6f47672 --- /dev/null +++ b/Source/Library.h @@ -0,0 +1,13 @@ +// Copyright (c) TribuFu. All Rights Reserved + +#pragma once + +#include +#include "TribuFu.h" + +/* + * Class: tribufu_TribuFu + * Method: Hello + * Signature: (Ljava/lang/String;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_tribufu_TribuFu_Hello(JNIEnv *, jobject, jstring); diff --git a/Source/TribuFu.java b/Source/TribuFu.java new file mode 100644 index 0000000..813884f --- /dev/null +++ b/Source/TribuFu.java @@ -0,0 +1,15 @@ +// Copyright (c) TribuFu. All Rights Reserved + +package tribufu; + +public class TribuFu { + /** + * A native method that is implemented by the 'TribuFu' native library. + */ + public native String Hello(String input); + + // Used to load the 'TribuFu' library on application startup. + public void LoadLibrary() { + System.loadLibrary("TribuFu"); + } +}