Applets
Locating Resource
Creating ImageIcon Using Relative File Names
Assume that image/us.gif is under the class directory, you can circumvent this problem by using a relative path as follows:
ImageIcon imageIcon = new ImageIcon("image/us.gif"); jlbl.setIcon(imageIcon);
This works fine with Java applications on all platforms, but does not work with Java applets because applets cannot load local files. To make it to work with both applications and applets, you need to locate the file using the URL class.