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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:47:15+00:00 2026-06-17T06:47:15+00:00

One year ago I’ve wrote JavaFX 2.0 application for my graduation work. But after

  • 0

One year ago I’ve wrote JavaFX 2.0 application for my graduation work. But after one year pass I have a problem with code, that worked before.

So, in code I want to get folder and list it’s files:

File dir = new File(getClass().getResource("media/images/backgrounds/").getPath()); 
File[] files = dir.listFiles();
for (File file : files) {
    list.add(file.toURI().toString());
}

and I’m getting java.lang.NullPointerException on line “for (File file : files) {“

System.out.print(getClass().getResource("media/images/backgrounds/").getPath());

returns
file:/D:/JavafxApp1/JavafxApp/dist/run2054723721/JavafxApp.jar!/javafxapp/media/images/backgrounds/

I don’t want make another method for reading files from stream from JAR file.This method of getting files have worked 100% one year ago, but why it doesn’t work now? Thanks!

  • 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-06-17T06:47:16+00:00Added an answer on June 17, 2026 at 6:47 am

    It won’t work because your folder is in a jar. I suppose one year ago they were not. I think you don’t need to have seperate code for the case where the directory is outside of a jar:

    I found this example that shows how you can list the files of a directory using getResourceAsStream. Then, in turn, you could access these resources by getResourceAsStream. You will never know whether you were inside or outside a jar 🙂

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

Sidebar

Related Questions

We implemented In-app Billing one year ago with no problems following the sample code
I used textmate to work with ruby code for over one year. Recently I
I have developed a web app a year ago aimed to work with IIS6.
This question was inspired by one I asked almost a year ago - any-orms-that-work-with-ms-access-for-prototyping
I am using Python code which was written one year ago. My OS is
I want to get the data every day within one year backward but I
I have learnt Python for about a month as a one year's PHPer.And I
I have been doing PHP stuff for almost one year and I have never
I have one custom config file. <Students> <student> <Detail Name=abc Class=1st Year> <add key=Main
How do I get todays date one year ago in C#?

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.