This topic is 4422 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Me again. [smile] I have an applet that needs to load a variety of images from a JAR archive. Unfortunately, these puppies are refusing to be accessed. Here's what I've tried already in an attempt to load the images:
		Image img = parentApplet.getImage( parentApplet.getClass().getClassLoader().getResource("Data&#47;Graphics&#47;"+folder+"&#47;"+key+".png") );

// and..

Image img = parentApplet.getImage( parentApplet.getCodeBase(), "Data&#47;Graphics&#47;"+folder+"&#47;"+key+".png" );


When I simply provide the data WITHOUT a JAR file, simply placed in the same directory, it works beautifully, so I don't think it's a directory issue. It only likes to bork when I package the information in a JAR archive. The rest of the applet loads just fine. I'm wide open to ideas, and as always: thanks in advance. You Java folks rock. [smile] EDIT: Oh, darn. Pretend those warped HTML codes GD.NET converted are really forward slashes.

##### Share on other sites
Hi!

You're saying your images are within a jar file? If so, is it the same jar archive that contains the code that tries to load them, or is it a different jar file?

Take a look at this thread:

http://www.gamedev.net/community/forums/topic.asp?topic_id=398094

Let us know whether this solves your problem or not. Remember that when you are trying to load things *from* a jar, the "current directory" is the classpath, and not necessarily the current directory (the directory where the jar you call things from is located).

##### Share on other sites
You may wish to try using a path with a leading "/" on it. Remember that JAR filenames are probably case sensitive.

I've looked at some of my code (which is J2ME Midlet not an Applet), and that's what I'm doing. From memory, I think that if you omit the leading "/", it probably doesn't work.

What exception are you getting?

Mark

##### Share on other sites
@Addictman: That did the trick. Thanks a lot for the linkage. [smile]

@Mark: It wasn't the leading forward slash, but your help is still appreciated. (and your rating is alread maxed, so 'thanks' will have to suffice, hehe)

1. 1
2. 2
frob
15
3. 3
Rutin
12
4. 4
5. 5

• 13
• 12
• 58
• 14
• 15
• ### Forum Statistics

• Total Topics
632124
• Total Posts
3004236

×