I am learning the basics of programming games in Java. For some reason every single time I created a program with an ImageIcon
, I would get an error:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at game.Picture.<init>(Picture.java:14)
at game.Main.<init>(Main.java:11)
at game.Main.main(Main.java:7)
After some experimenting, I found out that when I use the default package that eclipse creates, the program works fine. However when I create my own package, the program returns an error.
Below I have two identical programs, the only difference is one uses the default package and one uses my own package called "game"
I included a view of the package explorer in case it's a problem with the location of ship.png