diff --git a/pom.xml b/pom.xml
index 81324a5..c70248e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,8 +44,8 @@
3.1.1
- uncompress
- install
+ buildJin
+ compile
exec
diff --git a/src/main/java/com/zeekling/cn/jni/JniTest.java b/src/main/java/com/zeekling/cn/jni/JniLoader.java
similarity index 52%
rename from src/main/java/com/zeekling/cn/jni/JniTest.java
rename to src/main/java/com/zeekling/cn/jni/JniLoader.java
index ef251ff..9f2d0a1 100644
--- a/src/main/java/com/zeekling/cn/jni/JniTest.java
+++ b/src/main/java/com/zeekling/cn/jni/JniLoader.java
@@ -1,10 +1,10 @@
package com.zeekling.cn.jni;
/**
- * javac -encoding utf8 -h . JniTest.java
+ * javac -encoding utf8 -h . JniLoader.java
* gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -fPIC -shared jniTestNative.c -o libJniTestNative.so
*/
-public class JniTest {
+public class JniLoader {
/**
* native关键字,表明这个方法使用java以外的语言实现
@@ -14,12 +14,7 @@ public class JniTest {
static {
//加载jni库so
- System.load(JniTest.class.getResource("/libJniTestNative.so").getPath());
- }
-
- public static void main(String[] args) {
- //运行后,控制台打印出 hello world
- new JniTest().say("hello world");
+ System.load(JniLoader.class.getResource("/libJniTestNative.so").getPath());
}
}
diff --git a/src/main/native/com_zeekling_cn_jni_JniLoader.h b/src/main/native/com_zeekling_cn_jni_JniLoader.h
new file mode 100644
index 0000000..5da1e01
--- /dev/null
+++ b/src/main/native/com_zeekling_cn_jni_JniLoader.h
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include
+/* Header for class com_zeekling_cn_jni_JniLoader */
+
+#ifndef _Included_com_zeekling_cn_jni_JniLoader
+#define _Included_com_zeekling_cn_jni_JniLoader
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_zeekling_cn_jni_JniLoader
+ * Method: say
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_zeekling_cn_jni_JniLoader_say
+ (JNIEnv *, jobject, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/main/native/com_zeekling_cn_jni_JniTest.h b/src/main/native/com_zeekling_cn_jni_JniTest.h
deleted file mode 100644
index 69c8ce9..0000000
--- a/src/main/native/com_zeekling_cn_jni_JniTest.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include
-/* Header for class com_zeekling_cn_jni_JniTest */
-
-#ifndef _Included_com_zeekling_cn_jni_JniTest
-#define _Included_com_zeekling_cn_jni_JniTest
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: com_zeekling_cn_jni_JniTest
- * Method: say
- * Signature: (Ljava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_com_zeekling_cn_jni_JniTest_say
- (JNIEnv *, jobject, jstring);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/main/native/jniTestNative.c b/src/main/native/jniTestNative.c
index b09c371..e71d0ca 100644
--- a/src/main/native/jniTestNative.c
+++ b/src/main/native/jniTestNative.c
@@ -1,4 +1,4 @@
-#include "com_zeekling_cn_jni_JniTest.h"
+#include "com_zeekling_cn_jni_JniLoader.h"
#include
#ifdef __cplusplus
extern "C" {
@@ -8,7 +8,7 @@ extern "C" {
* Method: say
* Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT void JNICALL Java_com_zeekling_cn_jni_JniTest_say(JNIEnv* env, jclass cls, jstring j_str) {
+JNIEXPORT void JNICALL Java_com_zeekling_cn_jni_JniLoader_say(JNIEnv* env, jclass cls, jstring j_str) {
const char *c_str = NULL;
char buff[128] = { 0 };
jboolean isCopy;
diff --git a/src/test/java/com/zeekling/cn/jni/JniLoaderTest.java b/src/test/java/com/zeekling/cn/jni/JniLoaderTest.java
new file mode 100644
index 0000000..5a4c864
--- /dev/null
+++ b/src/test/java/com/zeekling/cn/jni/JniLoaderTest.java
@@ -0,0 +1,12 @@
+package com.zeekling.cn.jni;
+
+import org.junit.Test;
+
+public class JniLoaderTest {
+
+ @Test
+ public void testSay() {
+ new JniLoader().say("hello world");
+ }
+
+}