Currently I have a compiled JAR file as follows:
RunMe.jar
-GUIFile.class
-Main.class
-Notify.class
-resources
--sprites
---myimg.png
-com
--random
---package
----MakeNotify.class
Please explain to me how to access the PNG myimg.png inside MakeNotify.java
Thanks for all the advice in advance.
This depends, but generally, you want to use Class#getResource
or Class#getResourceAsStream
depending on how you want to read it.
Something like...
BufferedImage img = ImageIO.read(getClass().getResource("/resources/sprites/myimg.png"));
for example...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.