Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:49:55+00:00 2026-05-31T16:49:55+00:00

I am using Eclipse, and I wish to export some images in the img

  • 0

I am using Eclipse, and I wish to export some images in the “img” source folder along with my .jar, so they show up in the JAR.

My Heirarchy is :

Project>src>Package>FILE.java

Then in project is another source folder called :

img>IMAGE.png

I am currently linking to the images using :

lblNewLabel_1.setIcon(new ImageIcon("img/logo1.png"));

And that works fine, until I export it.

I am exporting it as an Runnable JAR file with Extract required libraries ticked, as the middle one will not allow the .jar to open. Extract allows it to open, but the images do not show.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:49:56+00:00Added an answer on May 31, 2026 at 4:49 pm

    Path are not the same when you load data inside a JAR.

    You can use this method to load image when you run from a JAR:

    /**
      * Create an instance of ImageIcon with the given path
      * @param path  String - path of the image
      * @return  ImageIcon - ImageIcon made with the image at the given path
      */
    private ImageIcon createImageIcon(String path) {
        if (path != null) {
            URL tmp = getClass().getResource(path.replace("\\", "/"));
            if(tmp!=null)
                return new ImageIcon(tmp);
            else
                return new ImageIcon();
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i wish to add external JAR to my project without using Eclipse GUI. i
Using Eclipse I want to view the source code for a core Java class
When using Eclipse or NetBeans IDE on a Java project I get to see
Im using Eclipse 3.4, EclipseMe 1.7.9. Im trying to deploy/create package a simple project
When using eclipse on ubuntu, for some reason it crashes/stops responding when loading an
Using eclipse 3.5, when I create a new maven project, m2eclipse automatically adds J2SE1.4
I'm using Eclipse to work on a Spring project that is controlled via Maven
I'm using Eclipse and wish to also use the Derby database and am having
Using Eclipse, is there a way to automatically copy a file/project's directory to a
I am using Eclipse 3.4.2 to develop my code. As part of my project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.