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

  • Home
  • SEARCH
  • 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 6357421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:09:44+00:00 2026-05-24T23:09:44+00:00

I just posted this question: How to distribute my Java program so that it

  • 0

I just posted this question: How to distribute my Java program so that it is runnable by double-clicking a single file? and while I got the runnable jar working, many things don’t work the way I’d want them to since my program cannot find the resources I want to use such as images and a SQLite database file.

In my file system, I have several .png images in the img folder and a database located at the project’s root folder named test.db

While my project was in Eclipse, I accessed my images using something like:

BufferedImage bufImg = ImageIO.read(new File("img/anImage.png"))

And I connected to my SQLite database using:

Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite:test.db");

Now, when I double-click my newly created runnable-jar, the resources cannot be found. I’d like to know how I’m supposed to access them and have my program work when it is not in a IDE.

I would also like to know how I can see what the exceptions are (if at all possible). Because right now, some pages stay gray because they don’t load because (I’m guessing) some resources cannot be found, but I have no idea if it’s only the database that is causing a problem or if it’s also the images.

Thanks a ton and sorry for asking two related questions in such a small timeframe!

  • 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-24T23:09:45+00:00Added an answer on May 24, 2026 at 11:09 pm

    There are no Files within a Jar, only resources, so most methods that use files will also accept resources.

    For instance ImageIO.read(…) has an overload that accepts URL and one that accepts InputStream. So try

    BufferedImage bufImg = ImageIO.read(MyClass.class.
             getResourceAsStream("img/anImage.png"));
    

    Just be sure to use a path relative to the class file location and your actual class name, or this.getClass()

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

Sidebar

Related Questions

I have posted this question on the Ext-GWT forums, I am just hoping that
This is a follow up to a question I just posted. I'm wondering how
I just posted this question and learned about <see cref=> , however when i
I just posted this as part of a reply to a question about the
This question is related to another question I just posted . I'm prepping for
I recently posted this question about codes for a gift-card-like voucher that users can
I posted this question yesterday evening, which has led me to discover a huge
I posted this question here before but there were no responses. I may have
This question to which I already found the answer is posted here in case
Edit: There is a somewhat strange solution to this question. Check my answer posted

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.