Issue
I'm trying to set an image icon on a label on NetBeans (for Mac). I set the image after imported it in the project folder: screenshot of selected image
When I try to run the project it fails with these errors:
Exception in thread "main" java.lang.NullPointerException
at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at Laboratorio.Login.initComponents(Login.java:52)
at Laboratorio.Login.<init>(Login.java:17)
at Laboratorio.Main.main(Main.java:26)
Login.java:52:
labelLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Laboratorio/Immagini/logo_550.png")));
The path of the image is: /Users/salvatore/NetBeansProjects/Laboratorio/src/main/java/Laboratorio/Immagini/logo_550.png
Can someone help me, please? Thanks!
Solution
I solved. I was using Java with Gradle (never used)... I always used Java with Ant. Now it works correctly with the same code.
Answered By - Salvo18