08-08-2013, 06:20 AM | #1 |
Junior Member
Posts: 7
Karma: 44444
Join Date: Aug 2013
Device: Kindle Paperwhite (5.3.4 JB)
|
Kindlet writing guide for the absolute beginner [PW]
Welcome! You may have noticed that it's easier to find reliable information about Atlantis than it is to find info on writing kindlets. I'm here to remedy that. After scrubbing through outdated wiki's and forum posts that assume you can read the author's mind, I have emerged triumphant.
Legal/moral note: I am not responsible if you crash, ruin, etc. your Kindle. These steps have worked for me, but they may not work for you. I do not believe that jailbreaks or further hacks void your warranty, but they very well may. 1. Prerequisites:
2. Setting it all up 2-1. Setting up the folders. Somewhere on your computer make a folder called "dev", or "kindleDev", or whatever you want. It doesn't matter. Just remember that I will be calling it "dev". Inside of dev, make a folder named "testProject". Inside testProject, make another folder that identifies you. Username is a common choice, and indeed I will be calling it the "username" folder. Inside that, another named "test". So mine is [dev]->[testProject]->[hotrootsoup] ->[test] Seemingly excessive for a test project, but good habits die young, or something like that. 2-2. Grabbing and preparing the KDK jar. We need the .jar file that holds the KDK's Java classes. There are actually quite a few jar files in the same folder as it that may have some fun classes. Don't feel obligated to grab those though, I don't even know if they are useful, so I just grabbed the main jar (Named below). It is located in /opt/amazon/ebook/lib/ on your kindle, and will have a name similar to (probably exactly) "Kindle-2.2.jar" Any way you want to fetch this is fine, but here are a few ideas:
Now, open the .jar file we just grabbed in your archive manager. (not in Java) If yours can't open .jar's, use 7zip. Drag the "com" folder from the .jar to inside the dev folder we made before. 2-3. Downloading the dev keys. Go to this page and download the newest key set (*.2012-11-06.zip as of writing) Unzip it, and drag "developer.keystore" into the dev folder. 2-4. Creating the manifest file. Make a new file in your dev folder called "test.manifest". Make sure you have file extensions visible, this can't be "test.manifest.txt". Open it in your (unix line-ending friendly) text editor. We are about to put some text inside it, but before you do, remember: Do NOT customize the text I'm about to post. Copy what is inside the following code tags verbatim. Just leave it alone. That being said, copy this text exactly into test.manifest: Code:
Manifest-Version: 1.0 Main-Class: <your.package.and.Class> Implementation-Title: <Your Kindlet Title> Implementation-Version: <your version> Implementation-Vendor: <Your Name or Nickname> Extension-List: SDK SDK-Extension-Name: com.amazon.kindle.kindlet SDK-Specification-Version: 2.1 Toolbar-Mode: persistent Font-Size-Mode: point You should now have a test.manifest in the dev folder, and a template.manifest in the same dev folder. 3. Creating the kindlet To preface: I'm sure this is much easier if you set it all up with Eclipse or NetBeans, but NetBeans wont run properly on my PC, and I would rather pour salt in my eyes than use Eclipse, so these instructions will assume neither program. Also, I'm a Java noob, so don't look to me for good practices. 3-1. Creating the files Create a file named "Main.java" in the path [dev] -> [testProject]->[username] -> [test] Now, open up the test.manifest file that resides inside "dev", and make the following edits.
3-2. Writing the code [Preface] You can test out this upcoming information with a premade "Hello World" type kindlet I wrote if you want to check your environment before writing code. The kindlet is a blank screen that pops up an alert when you tap it. MAKE SURE that Code:
Toolbar-Mode: in your manifest file, or you will have no way to exit the app, and your kindle will be crashed. The code is here, but heed the above warning, and remember to replace "username" with whatever you used as your username folder in the package line at the top of the code. [/preface] Obviously I'm not going to teach you Java, but I will explain the environment you are dealing with. Here is a link that explains the limits put on you compared to "normal" Java. It shows what classes you can use, and a link to the variant of Java SE that you are allowed that describes the bits of the core language that are different. (Certain things about generics I believe are restricted, etc.) Here are the classes that Amazon offers you. Those should explain it pretty well, and make sure to study the "AbstractKindlet" and "Kindlet" classes before reading any further. "KindletContext" is also important if you want to accomplish anything. Yes, I see you not reading what I just said to read. Seriously, read this page before doing anything else. It explains the life cycle of a kindlet, and what you need to do to get your main class to run. Don't forget, you're going to want to extend AbstractKindlet with your main class. And since you can't do much without it, make sure to read this page on KindletContext, which is the class of the object that gets passed to create(). Also, set Code:
Toolbar-Mode: Code:
Toolbar-Mode: persistent Code:
package testProject.username.test; Code:
import com.amazon.kindle.kindlet.(class); So yep, write your code inside the Main.java we created before, and run Code:
javac testProject/username/test/Main.java While still in the "dev" folder, run Code:
jar cvmf test.manifest Test.jar testProject Code:
jarsigner -keystore developer.keystore -storepass password Test.jar dktest Code:
jarsigner -keystore developer.keystore -storepass password Test.jar ditest Code:
jarsigner -keystore developer.keystore -storepass password Test.jar dntest Now rename Test.jar to Test.azw2 and put it in your kindle's "documents" folder. "documents" in the folder you've been dragging your fanfiction and whatnot into, and it is in the main folder you see when you plug in your kindle via USB. If I recall, it is technically /mnt/us/documents/ on the kindle's filesystem. Now eject and unplug your kindle, and click on the brand new kindlet shining you in the face =) |
08-08-2013, 06:29 AM | #2 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Nice one.
Thanks |
Advert | |
|
08-08-2013, 08:12 AM | #3 |
Evangelist
Posts: 456
Karma: 1287375
Join Date: Jan 2013
Location: West Gardiner, Maine
Device: Touch (5.3.7)
|
Makes me want to learn Java just to try this out. Thanks for spending the time to teach!!
|
08-08-2013, 09:04 AM | #4 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
And a worked example of how to automate a lot of that in an Ant makefile:
https://bitbucket.org/ixtab/ktcollec...=master#cl-157 But the write-up is nice, it will help a lot of people learn about the process. |
08-08-2013, 12:24 PM | #5 |
BLAM!
Posts: 13,477
Karma: 26012492
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Awesome! Feel free to cross-ref to this in the stuff you found on the Wiki!
|
Advert | |
|
08-08-2013, 07:37 PM | #6 | |
Junior Member
Posts: 7
Karma: 44444
Join Date: Aug 2013
Device: Kindle Paperwhite (5.3.4 JB)
|
Quote:
That reminds me: Much credit to the wiki, ixtab, various forum posts, Java docs, and many others for helping me learn all this. |
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
The absolute n00b guide to installing applications | Adam B. | iRex | 90 | 08-30-2013 07:01 AM |
Free Aquarium Beginner's Guide | pagansoul | Deals and Resources (No Self-Promotion or Affiliate Links) | 0 | 02-04-2009 01:00 PM |
LifeHack Beginner's Guide to E-Books | Bob Russell | News | 12 | 06-02-2008 04:09 PM |
How To Read eBooks: A Beginner's Guide | Bob Russell | Deals and Resources (No Self-Promotion or Affiliate Links) | 0 | 07-09-2005 11:13 PM |