简体   繁体   中英

Assets not loading inside applet's jar file

I have an jar file with an applet. This applet runs perfectly except for one thing: when I run the applet the program loads but the images don't. I know that is the only error. The manifest file inside the jar specifies another jar I use inside that, and I know it is imported correctly. What could be wrong?

Where are the images ?

-> If deployed in the jar, you need to access them from the classpath as a resource.

Something like,

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream input = classLoader.getResourceAsStream("/resources/image.jpg");
Image logo = ImageIO.read(input);

Applets typically have limitations, they can only connect to the server that served them.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM