-
Notifications
You must be signed in to change notification settings - Fork 2
/
JNInotes.txt
72 lines (52 loc) · 1.87 KB
/
JNInotes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--------------------------------------------------
Gotchas:
--------------------------------------------------
+export -p shows all PATH variables
+to export permanently use export command inside of:
~/.profile
~/.bash_profile
/etc/profile
--------------------------------------------------
Use JDK/JVM matching arch level of machine
(i.e. 32 or 64-bit must match gcc compilations if
using JNI)
Notes on JDK installation:
download jdk...tar.gz
cd to usr/local
sudo -s >>> to signn on
tar zxvf /home/dan/Downloads/jdk...
exit >> exit root user
add to ~/.profile
export JAVA_HOME=/usr/local/jdk...
export PATH=$PATH:$JAVA_HOME/bin
actually im using ~/.bashrc
--------------------------------------------------
Add C header library for JNI files for gcc through
environment variable examples:
C_INCLUDE_PATH=/usr/local/jdk1.8.0_31/include
export C_INCLUDE_PATH
C_INCLUDE_PATH=/usr/local/jdk1.8.0_31/include/linux
export C_INCLUDE_PATH
Use this one 31 for 64 bit or change 31 below to 25 for 32 bit:
C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/jdk1.8.0_31/include:/usr/local/jdk1.8.0_31/include/linux
Or this one specifing variable differently:
C_INCLUDE_PATH=${C_INCLUDE_PATH}:/usr/local/jdk1.8.0_31/include:/usr/local/jdk1.8.0_31/include/linux
This one includes current directory which is not needed:
C_INCLUDE_PATH=/usr/local/jdk1.8.0_31/include:/usr/local/jdk1.8.0_31/include/linux:./
//add path variable
export C_INCLUDE_PATH
//display
echo $C_INCLUDE_PATH
--------------------------------------------------
-> make java class
->dont forget C_INCLUDE_PATH
-> generate c header for dll / shared object
-> generate c source using header
-> created dll / shared object
-> invoke java code
javac HelloWorld.java ---> generate HelloWorld.java
javah -jni HelloWorld ---> generate HelloWorld.h
-> shared object
LD_LIBRARY_PATH=./ ---> set current directory
export LD_LIBRARY_PATH
java HelloWorld