Image img = parentApplet.getImage( parentApplet.getClass().getClassLoader().getResource("Data/Graphics&#<span class="java-number">47</span>;"</span>+folder+<span class="java-literal">"&#<span class="java-number">47</span>;"</span>+key+<span class="java-literal">".png"</span>) );
<span class="java-comment">// and..</span>
Image img = parentApplet.getImage( parentApplet.getCodeBase(), <span class="java-literal">"Data&#<span class="java-number">47</span>;Graphics&#<span class="java-number">47</span>;"</span>+folder+<span class="java-literal">"&#<span class="java-number">47</span>;"</span>+key+<span class="java-literal">".png"</span> );
</pre></div><!--ENDSCRIPT-->
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.
[java] The dreaded JARs! (Resource loading question)
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:
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).
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).
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement