Jni – java native interface

1,904 views
1,762 views

Published on

How to interact with native code from Java

Published in: Self Improvement
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,904
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
66
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Jni – java native interface

  1. 1. JNI – Java Native Interface How to persuade my Java application to talk to evil evil C native code
  2. 2. • WHAT? • WHY? • WHY NOT? • THE ACTUAL CODE • GOODIES
  3. 3. Er… WHAT? Java applications Native applications
  4. 4. But, but… WHY?
  5. 5. But, but… WHY? Allows native API function calls
  6. 6. But, but… WHY? Usage of existing native libraries
  7. 7. But, but… WHY? Execution of time-critical code
  8. 8. OK, so WHY NOT? Use of JNI should be avoided whenever reasonably possible!
  9. 9. Example Java native function declaration first:
  10. 10. Example
  11. 11. Example
  12. 12. Example
  13. 13. Example
  14. 14. Example
  15. 15. Example Careful!
  16. 16. Example
  17. 17. Example
  18. 18. Example
  19. 19. Exceptions?! Doable but annoying.
  20. 20. Other things to know • Forget about garbage collection • Java JVM is nazi about its memory space
  21. 21. I DON’T EXIST jernej@virag.si Skype: izacus

×