Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to set the URL of an image that is located in my resource folder in my src folder. It is always setting the URL to null. The image is there and everything is named correctly. What is the issue? Thanks!

My file structure:

  • sp1
    • src
      • resources
        • 01.png

Here is my code where I am trying to set the URL for the picture:

this.setImagePath(getClass().getResource("/resources/01.png"));

And the setImagePath is doing this, I am sure this is not the problem, because I followed the execution and it is setting it equal to null.

public final void setImagePath(URL imagePath) {
    this.imagePath = imagePath;
}

Solution

I had to clean the build and rebuild. It worked after that fix.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
727 views
Welcome To Ask or Share your Answers For Others

1 Answer

I had to clean the build and then rebuild. Works now.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...