mirror of
https://github.com/tribufu/tribufu-java
synced 2026-05-06 14:57:27 +00:00
Add JNI Sample
This commit is contained in:
parent
be03f71b22
commit
06b1398734
3 changed files with 40 additions and 0 deletions
12
Source/Library.c
Normal file
12
Source/Library.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
#include <jni.h>
|
||||
#include "TribuFu.h"
|
||||
#include "Library.h"
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_tribufu_TribuFu_Hello(JNIEnv *, jobject, jstring)
|
||||
{
|
||||
char *result = Hello("C");
|
||||
|
||||
return result;
|
||||
}
|
||||
13
Source/Library.h
Normal file
13
Source/Library.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
#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);
|
||||
15
Source/TribuFu.java
Normal file
15
Source/TribuFu.java
Normal file
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue