×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    7

    problem with images after building jar

    Hello,

    I`m developing a mobile phone game in JBuilder 2005 enterprise.

    The game works perfectly inside JBuilder and when using the built-in emulator.
    But if i build the game into a jar and jad using the archive builder and then run it on a mobile phone or using a phone emulator, i get a null pointer exception from the images i use.

    When developing with JBuilder, the images only work if i put them into the classes folder.
    After building, they go to the root.

    Should they be somewhere else, as the error must be coming from, the fact they were moved and the program can`t find them.
    In the code the address is just "/image1.png".

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    34
    I normally work from the command line, so i'm nto sure if this would apply completly, but it is perhaps worth giving it a shot.

    Try creating the .jar manually.

    Take a look at the options available wiht the jar tool, but something along the lines of this should do:

    jar cfmv MyJar.jar manifest.mf icon.png <list of all the files you want included in your jar>

    In order to save you writing out hundreds of names, i'd suggest also that you move all your images to an images folder, and update your code accordingly (not too difficult; search and replace "/" with "/images/"). That would make your command more like this:

    jar cfmv MyJar.jar manifest.mf icon.png images <list of all the files you want included in your jar>

    Hope that helps, or at least gets you one step forward in finding out the real problem,

    Åge Kruger

  3. #3
    Regular Contributor
    Join Date
    Aug 2003
    Location
    uk
    Posts
    232
    another possibility is its taking longer to load them on the real device and you are trying to use them before they have finished loading ..

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7
    would it help if, built it somewhere else like the wireless toolkit or something like that.

    Would it be as easy as open all the .java classes in the toolkit and the images and building it.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7
    I have the jad and jar working now.

    I used the built-in emulator in jbuilder to run the jad and jar,
    not the java classes themselves(just found out you could do that).

    i opened the browser on the phone and went to the address of the file on the webspace

    But when i try to download the game to a phone, it looks like its loading and then stops dead and thats it. any advise
    Last edited by conor026; 2005-04-06 at 11:58.

  6. #6
    Regular Contributor
    Join Date
    Aug 2003
    Location
    uk
    Posts
    232
    print the progress on the phones screen.

    You may also want to put exception handlers round everything that are capable of printing the exception onto the phones screen.

    If you do the later, test it works by deliberately causing a "devide by zero" exception, also I recommend having a method to change the display, which checks a boolean called bDisplayLocked before actually changing the display, that way an exception can set the display to a error message (on a form) and then lock the display so further code can not change it to something else.

    You may also want to open the jar up on the command line and see whats in it, its possible its not building it in exactly the same way, i.e. it may be creating more levels of dirrectories than you think or something.

    just type: jar -xf yourfile.jar

    Do this with the old jar and the new one and see if they are different.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7
    Just tried that command line thing.
    All the information is in the root and the classes were in a folder called game.

    Someone else, i know tried the file on an emulator and he said to change the name of the package from game to something else less common e.g. myAlienWarsGame


    Someone else tried it on a nokia 6610 and got the
    following error: "The requested item is too large to be loaded."
    The file is 49KB`s. The phone is a seires 40 version 1.0 with CLDC 1.0 and MIDP 1.0,does anyone know the filesize a phone like that can take?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×