Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 04-19-2012, 03:52 PM   #1
Zuljin
Junior Member
Zuljin will become famous soon enoughZuljin will become famous soon enoughZuljin will become famous soon enoughZuljin will become famous soon enoughZuljin will become famous soon enoughZuljin will become famous soon enough
 
Posts: 2
Karma: 529
Join Date: Apr 2012
Device: KT
Talking Working JNI library loading [with example]

Hello everyone.

I'm new owner of KT and I wanted to help community to create some more advanced application for Kindle.
I've investigated the topic of loading C/C++ libraries to Java using JNI interface.
Base on this http://codethesis.com/sites/default/...et=4&content=2 tutorial I was able to create solution that works very reliable and can:
  1. load system jni libraries - unfortunately this require additional permissions in /opt/amazon/ebook/security/external.policy. In attached example I was able to create jni wrapper for system library /usr/java/lib/libjnifsutil.so
  2. load libraries from any other directory - like /mnt/us/documents/ etc.
  3. load library from azw2/jar file - during start of application library is unpacked to cache directory (if isn't there already) and then loaded.

I think the only disadvantage of my solution is that we need to modify policy file and grant special permissions. To run my example application you have to edit
/opt/amazon/ebook/security/external.policy
and add following permissions (first 3 are mandatory, last is only for this specific application)
Code:
grant signedBy "Kindlet" {
  permission java.lang.RuntimePermission "loadLibrary.*";
  permission java.lang.RuntimePermission "createClassLoader";
  permission java.lang.RuntimePermission "getClassLoader";
  permission java.util.PropertyPermission "java.library.builtin.jnifsutil", "read";
};
My sample application doesn't do anything useful, so if you aren't developer do not bother installing it. Wait until I start using gathered knowledge to do something productive (like gui for MPD - with JNI it should be very simple to write).

If you are developer then try it, ask questions in this thread and use source code if you find it useful in your project.

P.S. Sorry for my English.
P.S.2 I suck at Java so if you find any bugs or opportunities to improvement in this code feel free to criticize me
Attached Files
File Type: zip kindlet_test_jni.zip (1.37 MB, 182 views)
Zuljin is offline   Reply With Quote
Old 04-20-2012, 05:33 PM   #2
hostar
Zealot
hostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of lighthostar is a glorious beacon of light
 
Posts: 138
Karma: 12324
Join Date: Dec 2011
Location: CZ
Device: Kindle 4 non-touch
I didn't study your post in detail or try to run demo app, but this looks interesting to me:
Quote:
like gui for MPD - with JNI it should be very simple to write
Good work
hostar is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading an already created library alansplace Calibre 3 08-08-2011 06:44 PM
Problems loading Library Books LizG News 1 07-09-2011 03:25 PM
Loading ASCM library book Dave W Calibre 1 03-21-2011 02:11 PM
Reader Library not loading after upgrade GSprunk Sony Reader 15 05-22-2010 05:41 PM
EBook library not loading lesjac Sony Reader 7 01-07-2008 12:40 PM


All times are GMT -4. The time now is 11:35 AM.


MobileRead.com is a privately owned, operated and funded community.