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 434037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:14:01+00:00 2026-05-12T20:14:01+00:00

When a JAR of an application is created, the images in the application no

  • 0

When a JAR of an application is created, the images in the application no longer appear. An example of our code for loading images is:

ImageIcon placeHolder = new ImageIcon("src\\Cards\\hidden.png");

We have no idea why this is happening. The application runs as expected if we do not compress it to a JAR; as a JAR, the images simply disappear. We also tried using URLs instead of ImageIcons, but that just causes the program not to run at all.

Any ideas?

EDIT: We are putting the image files into our JAR file in the correct paths, so that’s not the problem.

  • 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-12T20:14:01+00:00Added an answer on May 12, 2026 at 8:14 pm

    Check the API for the constructor you’re calling. The string you pass in is a file path – when the resources are packaged in a JAR, there is no file on the filesystem containing the image, so you can’t use this constructor any more.

    Instead you’d need to load the resources from a stream, using the classloader, and pull them into a byte array:

    byte[] buffer = new byte[IMAGE_MAX_SIZE];
    InputStream imageStream = getClassLoader().getResourceAsStream("src\Cards\hidden.png");
    imageStream.read(buffer, 0, IMAGE_MAX_SIZE);
    ImageIcon placeHolder = new ImageIcon(buffer);
    

    Needs more exception and edge-case handling, of course, but that’s the gist of it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a java application and packed it into a jar file on
I am new in android, I am using jackson-all-1.9.4 jar in my application for
In our application through the process of developing a lot of JAR files has
I created a simple web application and added log4J's jar in my lib folder
I have a GWT application, I created appBlueTheme.jar,appOrangeTheme.jar and added to BuildPath of project.
I have created a bundled JavaFX application jar with ANT on Windows 8 O.S.
Hi I have created a java application and created a jar file. Then I
I have created a Java application that has 2 Jar files. Jar1 is used
I have created an android application that uses android-support-v4.jar . Now when I add
I have created an executable JAR file for my Java application. If I double-click

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.