Now I managed to put the image in to the jar in netbeans - just put the image in the src folder and build, but the method still returns null. I also edit the manifest correctly. Any ideas?
You have to realize that the path passed to the getResource method is a path.
If the class file and the image file are in the same "directory" in the jar you can write:
- URL url = this.getClass().getResource("image.jpeg");
But suppose the class file is located in the jar in "/com/acme/widgets/Foo.class" and the image is in "/resources/pics/image.jpeg". In that case a "absolute" path in the jar makes more sense:
- URL url = this.getClass().getResource("/resources/pics/image.jpeg");
I can't say more because you haven't given any details.
One more thing: paths in jars are case sensitive, even in Windows!