java - Intellij can't find .png -


my intellij can't find local .png images.

private string craft = "craft.png"; imageicon ii = new imageicon(this.getclass().getresource(craft)); 

the .png located in same directory java files. don't understand why isn't working. using maven build, tried alternating resources java, still no luck :(

craft.png must placed src/main/resources, otherwise not copied classpath according maven rules. see this answer more details.

your code should changed to:

private string craft = "/craft.png";

here sample working project.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -