Trail: Deployment
Lesson: Java Web Start
Section: Developing a Java Web Start Application
Retrieving Resources
Home Page > Deployment > Java Web Start
Retrieving Resources
Use the getResource method to read resources from a JAR file. For example, the following code retrieves images from a JAR file.
// Get current classloader
ClassLoader cl = this.getClass().getClassLoader();
// Create icons
Icon saveIcon  = new ImageIcon(cl.getResource("images/save.gif"));
Icon cutIcon   = new ImageIcon(cl.getResource("images/cut.gif"));
The example assumes that the following entries exist in the application's JAR file:
Previous page: Developing a Java Web Start Application
Next page: Deploying a Java Web Start Application

Discuss
We welcome your participation in our community. Please keep your comments civil and on point. You may optionally provide your email address to be notified of replies — your information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.