Results 1 to 5 of 5
  1. #1
    Bobbo is offline Member
    Join Date
    Dec 2010
    Posts
    8
    Rep Power
    0

    Default Can a JPG be in the .JAR file?

    I have a program that has a JPG photograph displayed. I have to have the photograph in the same directory as the JAR file to find it. Is there a way to put the picture in the JAR file and have it be found by the program? I would rather just have the JAR file to distribute rather than the JAR file and the JPG.

    Thanks, Bobbo

  2. #2
    javanb is offline Member
    Join Date
    Dec 2010
    Posts
    10
    Rep Power
    0

    Lightbulb

    I haven't done this myself but it seems doable: How to include images in a JAR - CodeGuru Forums

  3. #3
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default

    You can achieve this is you use the 'classpath' to load the JPEG as a resource

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Jar files are a sort of zip archive so they can include any file you want.

    A less NB-centric discussion is available in the Packaging Programs in JAR files section of Oracle's Tutorial. The thread at CodeGuru linked to by javanb includes a useful post about how to access the images from within your program.

  5. #5
    Bobbo is offline Member
    Join Date
    Dec 2010
    Posts
    8
    Rep Power
    0

Similar Threads

  1. Replies: 6
    Last Post: 12-01-2010, 05:31 AM
  2. Replies: 1
    Last Post: 08-04-2010, 03:24 PM
  3. Replies: 0
    Last Post: 07-15-2010, 01:23 PM
  4. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  5. Replies: 7
    Last Post: 05-23-2008, 03:46 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
  •