accessing images in a jar (already read other threads but not resolved )
Hi everyone,
I know this topic has already been answered and I have read most of them and tried to all the solutions but still I can not get my images in the jar...
for uploading icons and images in to my java application I use the following method:
private static ImageIcon createIconImage(String imageFile) {
ImageIcon image = null;
String extention = ".gif";
String imageLocation = "../" + imageFile + extention;
URL imageURL = MyClass.class.getResource(imageLocation);
System.out.println(imageURL);
if (imageURL == null)
System.err.println("The file: " + imageLocation + " does not exist !");
else
image = new ImageIcon(imageURL);
return image;
}
My directories are situated as bellow:
[javadev]
|
+-[mypackage]
||
|+[AllClassFolders]
|||
||+[folder1]
|||
||+[folder2]
||
|+[icons]
|||
||.- icon1.gif
||.- icon2.gif
||
|+[img]
|||
||.- img1.gif
||.- img2.gif
|
+ -[test]
+ -[anotherdirectory]
But what ever i do i can not have access to these images. In my manifest file I have:
Main-Class: myMainClass
Class-Path: swing-layout-1.0.jar (which is a jar file with some of swing layouts)
Does anyone has any idea how I can solve this problem? I have almost spent 5 hourse to solve this problem with different proposed solutions in this forum but no result.. I am almost depressed ;)
So I would be greatful if I someone can help me.
Take care

