My icons are not being add to.JAR

Good afternoon, I'm having a problem when compiling my application.

I'm using Apache NetBeans 11.0 Java 8

I'm having trouble setting an image in a JLabel.

Returns Me Expection in thread" AWT-EventQueue-0 " java.lang.NullPointerException at javax.swing.ImageIcon.(ImageIcon: 217) at br.house.main.mainBotPainel.initComponents (mainBotPainel.java:63) ...

All images were add in the assets folder. Follow attached 2 prints.

Since nothing worked, I took the .JAR and I had to open with winRAR and inside it did not contain the assets folder, that is, it was encapsulated together with the jar by Netbeans. What am I doing wrong?

The images and icons were add in the assets folder

The line of code where the error occurs

Author: Woss, 2019-09-10

1 answers

I got the help in GUJ for the solution of the problem and I come here to share if in the future someone is going through the same problem.

I was asked by a Guj user to post the expanded tree of my project's 'Files' tab on NetBeans.

expanded Files tab tree

I received the following solution after the print above.

"cool, your problem is not NetBeans much less Java but its folder structure. This is a Maven project, so you have to follow a certain folder structure (so as not to be changing pom.xml).

Your Java fonts are already in the right place, which is the following folder:

Src \ main \ java Your images and other resources need to be in the following folder:

Src \ main\resources Then create this folder and move the assets folder into it that will work."

And it was potato. Problem solved!

 1
Author: Thiago Sartori, 2019-09-11 00:12:55