2 Replies Latest reply: Oct 22, 2010 6:51 AM by 807405 RSS

    download .res file save it to phone memory then use it.

    843849
      hello i am trying to download a resources file (LWUIT .res file) from the web and save it in a certain directory and file i create using FileConnection API and after that i open the file as InputStream and use that stream to initialize my resource.


      //The mydir directory & MyResource have been created and filled with the downloaded data i made sure it happened.
      //the following code is to open the file as InputStream inorder to create the Resource.

      fileconn = (FileConnection) Connector.open("file://sdfsd/root1/mydir/MyResource.res", Connector.READ);
      InputStream is = fileconn.openInputStream();
      resource = Resources.open(is);
      fileconn.close();

      then to make sure i can use the contents of the resource file i try to display an image from it.
      Form mainform=new Form();
      Image image=null;
      image = resource.getImage("ImageInsideRes");
      Label toholdimage = new Label(image);
      mainform.addComponent(toholdimage);
      mainform.show();

      i made sure everything is right all the paths and i even made sure that the directory and file are beeing created but when i Run it i get this error

      java.lang.IllegalArgumentException:
      at javax.microedition.lcdui.ImmutableImage.<init>(Image.java:906)
      at javax.microedition.lcdui.Image.createImage(Image.java:367)
      at com.sun.lwuit.impl.midp.GameCanvasImplementation.createImage(GameCanvasImplementation.java:615)
      at com.sun.lwuit.Image.createImage(Image.java:533)
      at com.sun.lwuit.EncodedImage.getInternal(EncodedImage.java:101)
      at com.sun.lwuit.EncodedImage.getWidth(EncodedImage.java:159)
      at com.sun.lwuit.plaf.DefaultLookAndFeel.getPreferredSize(DefaultLookAndFeel.java:487)
      at com.sun.lwuit.plaf.DefaultLookAndFeel.getLabelPreferredSize(DefaultLookAndFeel.java:472)
      at com.sun.lwuit.Label.calcPreferredSize(Label.java:327)
      at com.sun.lwuit.Component.preferredSize(Component.java:1217)
      at com.sun.lwuit.Component.setPreferredSize(Component.java:377)
      at downloadjar.startApp(+169)
      at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:44)
      at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:375)
      at com.sun.midp.main.Main.runLocalClass(Main.java:477)
      at com.sun.midp.main.Main.main(+80)
      Execution completed.

      Does anyone have anyidea what am i doing wrong??
      Please help..
      Thank you
        • 1. Re: download .res file save it to phone memory then use it.
          843849
          java.lang.IllegalArgumentException:
          at javax.microedition.lcdui.ImmutableImage.<init>(Image.java:906)
          at javax.microedition.lcdui.Image.createImage(Image.java:367)
          at com.sun.lwuit.impl.midp.GameCanvasImplementation.createImage(GameCanvasImplementation.java:615)
          at com.sun.lwuit.Image.createImage(Image.java:533)
          at com.sun.lwuit.EncodedImage.getInternal(EncodedImage.java:101)
          at com.sun.lwuit.EncodedImage.getWidth(EncodedImage.java:159)
          at com.sun.lwuit.plaf.DefaultLookAndFeel.getPreferredSize(DefaultLookAndFeel.java:487)
          at com.sun.lwuit.plaf.DefaultLookAndFeel.getLabelPreferredSize(DefaultLookAndFeel.java:472)
          at com.sun.lwuit.Label.calcPreferredSize(Label.java:327)
          at com.sun.lwuit.Component.preferredSize(Component.java:1217)
          at com.sun.lwuit.Component.setPreferredSize(Component.java:377)
          at downloadjar.startApp(+169)
          at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:44)
          at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:375)
          at com.sun.midp.main.Main.runLocalClass(Main.java:477)
          at com.sun.midp.main.Main.main(+80)


          doesn't any one know why does this kind of errors usually occur???
          am at a dead end here so any ideas???
          • 2. Re: download .res file save it to phone memory then use it.
            807405
            I have the same problem with EncodedImages.
            It used to work when i was running on javaME30 emulator.
            But when i have switched to wtk2.5 it stopped run.
            Can somebody help us?