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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:44:16+00:00 2026-06-18T14:44:16+00:00

I have a NetBeans project. In the project directory, I’ve created some additional directories

  • 0

I have a NetBeans project. In the project directory, I’ve created some additional directories for keeping resources (images). So the path of one of my images is “/res/imgs/on.png” (“res” and everything in it is created by me). Then I’ve added the “res” directory to my project’s sources (Right-click on my project in NetBeans -> Properties -> Sources -> Add Folder (for Source Packages Folder section)). And I’ve accessed to the URL of the image in my project using the following code:

URL url = Class.class.getResource("/imgs/on.png");

And this was successful – just a few days ago. Today, after this code execution, url variable was set to null. But when the code was modified to this:

URL url = Class.class.getResource("/imgs");

The (url != null) was true.

Next, I’ve created a yet another project, where I’ve done exactly the same manipulations (that is, created subdirectories in the project folder, loaded some files to it and tried to execute a code, similar to these I’ve written above). And these manipulations were successful. After that, I’ve returned to my first project (that initialized url to null when tried to access “/imgs/on.png”). And it turned out, that everything was again OK there and the image’s URL loaded successfully…

So, the question is, what was the problem? Is this a NetBeans bug, or maybe I’m doing something in a wrong way?

  • 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-18T14:44:17+00:00Added an answer on June 18, 2026 at 2:44 pm

    Probably by some Netbeans compile/clean glitch, the “on.png” was not in the classes directory and therefore was not found on the classpath. After a restart or any operation that would cause Netbeans to rescan the source folders, it was back there.

    By the way instead of Class.class.getResource() you should use the caller’s class, e.g. this.getClass().getResource() to use the same class loader.

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

Sidebar

Related Questions

I have one java project in netBeans. There are some packages, and classes in
I have this problem getting my newly created php project on Netbeans work on
I currently have a NetBeans php project setup to sync from my user directory
I have bunch of groovy scripts in various directories (not necessarily netbeans/maven project dirs).
I have added some external libraries to my java project (in netbeans). Is it
I have an project in NetBeans. I made some preparations to make database migration
I have a netbeans project with a directory tree like this: <source folder> |
I have a NetBeans project set up with a bunch of source classes and
I have a NetBeans project and the Mercurial repository is in the project root.
I have a NetBeans java project. This project ( src folder) is composed of

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.