For anyone that is having this issue the resolution was to (actually) add the folder to the class path.
Contrary to what you will find via google, the path cannot be added via project properties (apache NetBeans 12.6). At least not under the file/project properties/libraries menu item.
(I cant use the right click method to get to project properties due to NetBeans mishandling screen size and menu items).
Right click 'Libraries' in the project browser and select 'Add Jar/Folder'.
Hello:
Using NetBeans on Ubuntu.
I am trying to load an image into my class but am getting null pointer error.
I can see the image in my project files list.Exception in thread "main" java.lang.NullPointerException at java.desktop/sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:692) at java.desktop/sun.awt.SunToolkit.getImage(SunToolkit.java:728) at oddcouplepoker.GameCanvas.<init>(GameCanvas.java:23)
h t t p s : //imgur.com/a/dIZpAAT
This is the line that is throwing errors:
From this constructor of a class that extends JPanel:this._backgroundImage = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("resources/images/oddcouple.png"));
I have been searching all over and I cannot find the answer.public class GameCanvas extends JPanel { private Image _cardsTileset; private Image _backgroundImage; public GameCanvas(String cardsImagePath, String backgroundImagePath) { //this. _cardsTileset = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(cardsImagePath)); System.out.println(backgroundImagePath); this._backgroundImage = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("resources/images/oddcouple.png")); System.out.println("past"); }