This content has been marked as final. Show 16 replies
I'd guess it's something with the packaging.
The picture works fine when I run an html file on my computer with the <applet> code.
It's the jar file that doesn't display it.
I've never used jar files before. I'm using JCreator, I simply clicked "Create Jar File" and hoped it would all work. It listed the files it added, and it seemed to add all the necessary ones.
So I'm not sure what to do.
I'm not sure what it's path IN the jar file is, now that I think of it.
I use it in my code like this:
Although I guess I would need to change the path to the jar's .gif path, huh?
backImage = getImage(getCodeBase(), "Pong.gif");
Only problem is I don't know how to find it. How do I find the path of the .gif in the jar?
Only problem is I don't know how to find it. How do II don't use JCreator so I have no idea how to do it there.
find the path of the .gif in the jar?
If you have the JDK installed, then on the command line you can do:
(substituting your actual jar file name of course), and it should list the jar file contents.
jar tvf MyJar.jar
I use it in my code like this:Probably. I think that getCodeBase returns the URL to the jar file, and if Pong.gif is not at the root of the jar file, the above wouldn't find it. I could be wrong though. You should feel free to add some debugging statements to the code to see if the values look right.
Although I guess I would need to change the path to
> backImage = getImage(getCodeBase(), "Pong.gif");
the jar's .gif path, huh?
Well, I did what you said on the command line.
Here's what it gave me:
0 Fri Dec 29 20:19:52 PST 2006 META-INF/
71 Fri Dec 29 20:19:52 PST 2006 META-INF/MANIFEST.MF
173 Fri Dec 29 16:54:56 PST 2006 Applet.html
4052 Fri Dec 29 19:54:58 PST 2006 Ball.class
4301 Fri Dec 29 19:54:56 PST 2006 Ball.java
3918 Tue Jun 24 15:57:36 PDT 2003 beep_1.au
3138 Tue Jun 24 15:58:34 PDT 2003 beep_2.au
5540 Fri Dec 29 19:48:48 PST 2006 Main.class
3949 Fri Dec 29 19:48:46 PST 2006 Main.java
1996 Fri Dec 29 20:19:24 PST 2006 Player.class
1605 Fri Dec 29 20:19:24 PST 2006 Player.java
3003 Fri Dec 29 15:00:16 PST 2006 Pong.GIF
Looks like Pong.GIF is in the root, doesn't it?
Not sure why it wouldn't be working.
I don't really understand the getCodeBase(), I kinda just... use it. Is that the problem?