I just fancied writing an old style retro shoot them up to run as an applet on the web. The coding part has gone fine and I'm moderately pleased with the result but I now want to put everything into a jar file and it's not really working. I can produce the jar file and it looks ok but it sits in the web directory with all the original files - if I remove the original files then it stops working ie remove the wav files and the sound stops. This suggests to me that the jar file is being ignored. Can anyone offer advice?
The files I want to package are all in the same directory:
The source code I used to make the jar was :
jar cfm C:\Java\Game\TheSwarm.jar C:\Java\Game\Manifest.txt C:\Java\Game\*.class C:\Java\Game\*.wav C:\Java\Game\*.jpg
The manifest stuff. Must admit if there's only one class and it's an applet then shouldn't it work this stuff out? I tried including a main method in the applet but that doesn't seem to help. There is a return at the end of the last line :
It turned out I had a bunch of different problems and I thought I might as well say how things got fixed in case any one else has a similar issue.
I had multiple classes (actually old versions of the same program) in the same directory and my command was placing them all in the same jar file. You can see what's in your jar file by typing:
jar -tf MyFile.jar
You shouldn't include the ".class" part of the name in the manifest file. Also ensure there is a newline after the name of the main class.
I was compiling the jar file on my local PC and the jar was keeping the directory name when I transfered it to my linux server ie it couldn't find C://java/... I solved this by making the jar file on the linux box which didn't bother storing the directory structure if it was all in the same directory.
So in the end I built the classes and stuff on my XP PC using:
I checked that the applet was working using a simple web page that pointed to the applet:
I then transfered the class, the audio files and images to the linux box. Created a simple manifest file. Then built the jar.
I then deleted the files from the directory leaving the jar file and completed a few tests just to make sure all was fine.