Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts

    JAR file, saving images

    I have coded a program but i need t to run on a jar file, i have been using the following code to construct it
    jar cmf MyManifest Jarfile.jar *

    It creates the jar file but does not put the images into the jar file and so when I run the program none of the images show up, how do i get this to work without having to issue all the images with the jar?


    Thanks

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by littlemiss View Post
    It creates the jar file but does not put the images into the jar file and so when I run the program none of the images show up, how do i get this to work without having to issue all the images with the jar?
    how else do you intend to package the images?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I got to work in a non static context, so for everyone else having the same problem here is what i did:


    URL url1 = this.getClass().getResource("image);
    private ImageIcon Image = new ImageIcon(url1);


    But i dont know how to get it to work in a static context.

  • #4
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    use the thread context classloader
    Code:
    URL url1 = Thread.currentThread().getContextClassLoader().getResource("image");
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • Users who have thanked shyam for this post:

    littlemiss (02-11-2008)


  •  

    Posting Permissions

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