Results 1 to 20 of 20
  1. #1
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Smile Regarding jar files

    i am done making jar files, i also included the images that is needed for my GUI, how come that when i run my program on other Computer, my images cannot be displayed? the only thing displayed is the GUI itself even the button images that i assigned didn't work, i included them in my codes and i also included them when i packaged the jar file, what should i do about this? please help me,,:)

    thanks,

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    You say that when you run the jar package it's working fine. But in different PC it's not, images only is missing.

    Try this, on the second machine extract your jar file. Then try to run your same jar file which you try to run before. I'm sure it's work.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,332
    Rep Power
    25

    Default

    How is your code reading the image files? From the jar or from the disk? Do you use a getResource method or a File class method?
    The File class doesn't work to read from a jar file.

  4. #4
    Join Date
    Oct 2008
    Posts
    68
    Rep Power
    0

    Default

    make sure the images are part of your jar file....

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  6. #6
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    i used a code wherein i access image file through the disk which is particularly stored in my C:,,, the problem is that when i move that image , it will not be displayed,,, the first thing i've done is that i included that file in my jar compilation,, should i extract the jar file in every computer where i will distribute my program? isn't it kinda odd? is there a way to make things much easier for my firends?
    thanks for the reply guys

  7. #7
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    for priyanka,,,,,

    the images are part of my jar file..

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by kirly View Post
    i used a code wherein i access image file through the disk which is particularly stored in my C:,,, the problem is that when i move that image , it will not be displayed,,, the first thing i've done is that i included that file in my jar compilation,, should i extract the jar file in every computer where i will distribute my program? isn't it kinda odd? is there a way to make things much easier for my firends?
    thanks for the reply guys
    Yes, it's really bad thing to do in each computer. I just want to show you that there is an error with image path setting. When you build your application keep your image folder inside the project folder.

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,332
    Rep Power
    25

    Default

    If you put all the resources (like images) your program needs in the jar file, you will be able to access/read them in the program that runs from the jar file. The trick is to use the getResource methods to access the files in the jar NOT the File classes.
    There are code examples on this forum on how to use getResource methods to read files.

  10. #10
    Loop is offline Member
    Join Date
    Sep 2008
    Posts
    36
    Rep Power
    0

    Default

    Whoa, Norm that's a nice tip... *Puts in permanent memory*

  11. #11
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    guys, the situation i am in ryt now is like this,, i declared an ImageIcon for my label, but wen i compiled it in the jar the label dont't have imageIcon anymore, i am puzzled because i included my image file in my jar...any suggestion guys?

  12. #12
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    i also have a problem regarding memory usage..(CPU Memory).. when i exit my program thru clicking the close button, the process doesn't end, i discovered it when i view the task manager, and then the process for my application is still there,, i included a windowDistroyer in my program but still the closed program still access memory..any idea guys?

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,332
    Rep Power
    25

    Default

    Your app can close its windows and stay running without GUI. To exit the app, call System.exit(). Also the JFrame class has a method call (setDefault...) that will exit the app when the frame is closed.

  14. #14
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    Norm,, i did included System.exit() in my program,, but i did this

    System.exit(0);

    is there any difference with

    System.exit();

    i think it requires an int.. isn't it?

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,332
    Rep Power
    25

    Default

    Yes.
    Its always best to read the API doc when using methods you are not sure of. I don't always type correct java and try not to give completely correct answers to cause you to have to look them up.

  16. #16
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    ok,, i got it.. i'll try to modify my program to see if there will be a change..

  17. #17
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    norm here is the fragment of my code, hope you make a comment out of this,,

    public static void main (String [] args)
    {
    up2 m = new up2();
    m.setVisible(true);

    m.addWindowListener(new WindowAdapter()
    {
    public void windowClosing( WindowEvent e )
    {
    System.exit(0);

    }
    }
    );
    }




    tha'ts my main method, but if i close my GUI,, the process is still there,, it won't end even if i included the code above..

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,332
    Rep Power
    25

    Default

    What object type is m/up2? Is the listener called? Put a println() before the System.exit. I'd bet it is not being called.

    Use the @Override statement before any method call being overriden in an adapter class. There won't be a compiler error if you misspell the method name and don't use @Override.

  19. #19
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    ok i got it,, i'll try your suggesstion, anyway, the m is an object of the class up2, up2 is the name of my class that inherits the JFrame...

  20. #20
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    Read the API fo JFrame and find the method mentioned in reply #13. One line of code will save you the 5 or so lines required for a WindowListener/Adapter, and is cleaner.

    db

Similar Threads

  1. Behaving text files like binary files
    By Farzaneh in forum New To Java
    Replies: 2
    Last Post: 08-27-2008, 03:20 PM
  2. Writing to files within jar files
    By erhart in forum Advanced Java
    Replies: 0
    Last Post: 02-04-2008, 02:50 AM
  3. Text and image files within jar files
    By erhart in forum Advanced Java
    Replies: 8
    Last Post: 01-19-2008, 04:43 AM
  4. how to convert mpeg files to .wav files
    By christina in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 04:14 AM
  5. convert xls files into pdf files
    By bbq in forum New To Java
    Replies: 3
    Last Post: 07-20-2007, 03:56 AM

Posting Permissions

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