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 09-10-2011, 12:45 AM   #1
liuto
Connoisseur
liuto is on a distinguished road
 
Posts: 50
Karma: 70
Join Date: Nov 2010
Device: Kindle DXG / Kindle 3
Load image from jar file

Hi,

Could anyone help me to figure out why this code just get Kindle show me 'An error occurred openning the title'?

I just try to load a png image in my Kindlet. looks like it get error on 'Create' method.


Code:
package kapp;

import com.amazon.kindle.kindlet.AbstractKindlet;
import com.amazon.kindle.kindlet.KindletContext;
import com.amazon.kindle.kindlet.ui.KImage;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;

public class Main extends AbstractKindlet {

    private KindletContext ctx;
    private Image im;
    private KImage card;

    public void create(KindletContext context) {
        this.ctx = context;

        URL urlImage = getClass().getResource("Images/xxx.png");
        this.im = Toolkit.getDefaultToolkit().createImage(urlImage);        
        this.card = new KImage (im);

        try {
            ctx.getRootContainer().add(this.card);
        } catch (Throwable t) {
            //ctx.getRootContainer().
            //t.printStackTrace();
        }
    }

    public void start() {
        try {
            //this.card.setBounds(256, 56, 75, 108);
        } catch (Throwable ex) {
            //ex.printStackTrace();
        }
    }

    public void stop() {
    }

}
By move the 'try' statment, I can identify this line causes the error:

Code:
           this.im = Toolkit.getDefaultToolkit().createImage(urlImage);
but I don't know why......

Last edited by liuto; 09-10-2011 at 12:56 AM.
liuto is offline   Reply With Quote
Old 09-10-2011, 02:23 PM   #2
liuto
Connoisseur
liuto is on a distinguished road
 
Posts: 50
Karma: 70
Join Date: Nov 2010
Device: Kindle DXG / Kindle 3
Actually, I got the crash log file said:


[9/10/11 2:18 PM] Hello from Liuto (v. 0.2)

java.lang.NullPointerException: null
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.jav a:168)
at sun.awt.SunToolkit.getImage(SunToolkit.java:231)
at hello.Main.create(Main.java:42)
at com.amazon.kindle.kindlet.internal.lifecycle.f.cal l(ahb:456)
at edu.emory.mathcs.backport.java.util.concurrent.Fut ureTask.run(aq:131)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor.a(vp:1502)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.run(vp:971)
at java.lang.Thread.run(Thread.java:694)
at java.lang.Thread.startup(Thread.java:758)
liuto is offline   Reply With Quote
Old 09-10-2011, 04:32 PM   #3
liuto
Connoisseur
liuto is on a distinguished road
 
Posts: 50
Karma: 70
Join Date: Nov 2010
Device: Kindle DXG / Kindle 3
Do you guys really get this line work?

Code:
urlImage = this.getClass().getResource("xxx.png");
I always get it return NULL whatever where I put the xxx.png

Could anyone give me a hint?

Thanks,
Liuto
liuto is offline   Reply With Quote
Old 09-11-2011, 10:56 AM   #4
liuto
Connoisseur
liuto is on a distinguished road
 
Posts: 50
Karma: 70
Join Date: Nov 2010
Device: Kindle DXG / Kindle 3


Finally, I got my Kindlet run!

Some notes here:
1. JDK 1.6 (compile with 1.4 compatible)
2. Java ME (CDC, PBP 1.1 profile) ... I am not fully understand what the hell of this shit is, but it is must.
3. Manifest file must be set exactly correct ! But I don't know what exactly should be. These settings are just work anyway:

Code:
Manifest-Version: 1.0
Implementation-Title: Hello from PBP1.1
Implementation-Version: 0.2
Implementation-Vendor: Liuto
Network-Access-Grants: sponsored
Implementation-URL: http://may10.ca/
Amazon-Cover-Image: image/app.jpg
Main-Class: com.nowhere.sample.App

Last edited by liuto; 09-11-2011 at 01:04 PM.
liuto is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
iLiad how to load the image of firmware to copy some files tigerszheng iRex 2 05-16-2011 07:17 PM
epub load time, possible file optimizations? takamatsu Kobo Reader 8 07-09-2010 03:54 AM
Help to load file in calibre customized plugin William A Amazon Kindle 0 03-21-2010 12:57 PM
PRS-600 Cannot load scientific american pdf file mjsalman Sony Reader 11 02-06-2010 12:50 PM
Could Book Designer Load an LRF File? Fitzwaryn Sony Reader 6 01-30-2008 04:43 AM


All times are GMT -4. The time now is 12:49 PM.


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