palysek
palysek

Reputation: 11

Resources in NetBeans

Hi :) I have some problem with my resources in NetBeans. Already I add them into project, and when I run whole project in NetBeans, everything works fine :) But when I clean it and build, I have no idea where I should have those resources (app can't find my image).

Every image and font are in my packages (example: com.project.resources.images), command which I used to get it is:

ImageIO.read(this.getClass().getResource(path)

If someone could help me it would be awesome.

Upvotes: 1

Views: 1051

Answers (1)

Joop Eggen
Joop Eggen

Reputation: 109567

Look into the application jar (a zip format), with 7zip, WinZip or so, if you find the resources, you can do something like getClass().getResource("/resources/someimg.png").

There is one issue: in a jar (and on Linux/MacOSX) the file names are case sensitive, under Windows not, so make sure about the correct case-sensitive spelling.

If it seems that on running from the IDE the files are on the class path but do not get into the jar, better pick a Maven build infrastructure with predefined directory conventions.

Upvotes: 1

Related Questions