java - Can't load file from jar archive -


i'm beginer programmer , tried write classic snake game. use maven build project , work intellij idea. putted texture folder

src\main\resources\com\github\poseydon42\snakegame\assets 

it's simple png file named snake_head.png. tryied load image code, using thisa code

imageio.read(new file(getclass().getresource("/com/github/poseydon42/snakegame/assets/snake_head.png").getfile())); 

but have error:

exception in thread "main" java.lang.nullpointerexception @ com.github.poseydon42.snakegame.game.<init>(game.java:22) @ com.github.poseydon42.snakegame.main.main(main.java:10) 

how can load image.

p.s.: don't work in ide , in cmd using built jar file.

try instead

imageio.read(getclass().getresourceasstream("/com/github/poseydon42/snakegame/assets/snake_head.png"))); 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -