View RSS Feed

Recent Blogs Posts

  1. Accessing Resources in a JAR File

    by , 11-28-2011 at 07:05 PM (My Java Tips)
    JAR files are used to deploy applications. They comprise of java classes and other resources like images etc. In this post, I will explain how to access resources packed in a JAR file.



    To access resources in a JAR file, we use getResource method. Lets do this practically. The code snippet provided shows how to retrieve images from a JAR file.

    Java Code:
    // Get current classloader
    ClassLoader cl = this.getClass().getClassLoader();
    // Create icons
    ...
    Categories
    Java SE