Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "java.net.URL.toExternalForm()" because "location" is null.

The error is from this line of code:

home.addItem(new ModelItem(ID++, "Original Nuggets Meal", "", 90, "KFC", new ImageIcon(getClass().getResource("icon/img2.png"))));

i use the correct folder as it is in a package in the same source of the file. please help!

Recommended Answers

All 2 Replies

AFAIK, Netbeans requires those images to be in the resources folder. So much omitted about the dev environment here.

okay so i got it fixed by deleting the files in the recycle bin, probably caused by alot of deletion of similar files that caused this error somehow. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.