-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4476fea UseJava: Add support for javah tool
- Loading branch information
Showing
7 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#include <jni.h> | ||
#include <stdio.h> | ||
|
||
#include "B.h" | ||
|
||
JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject) | ||
{ | ||
printf("B\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class B | ||
{ | ||
public B() | ||
{ | ||
} | ||
|
||
public native void printName(); | ||
|
||
static { | ||
try { | ||
|
||
System.loadLibrary("B"); | ||
|
||
} catch (UnsatisfiedLinkError e) { | ||
System.err.println("Native code library failed to load.\n" + e); | ||
System.exit(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
project(helloJavah Java CXX) | ||
|
||
cmake_minimum_required (VERSION 2.6) | ||
set(CMAKE_VERBOSE_MAKEFILE 1) | ||
|
||
find_package(Java COMPONENTS Development) | ||
include (UseJava) | ||
|
||
# JNI support | ||
find_package(JNI) | ||
|
||
add_jar(hello3 B.java HelloWorld2.java) | ||
create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) | ||
|
||
add_library(B SHARED B.cpp) | ||
add_dependencies(B B_javah) | ||
|
||
target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} | ||
${JAVA_INCLUDE_PATH} | ||
${JAVA_INCLUDE_PATH2}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class HelloWorld2 | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
B b; | ||
b = new B(); | ||
b.printName(); | ||
System.out.println("Hello World!"); | ||
} | ||
} |