File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes jar files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "jar files?" Watch "jar files?" New topic

jar files?

Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 260
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 :
Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: TheSwarm_v23.class

The applet call in the web page is :
<applet code=TheSwarm_v23.class
width=120 height=120>

Other small issues:
If possible I'd like to also have a splash screen for the game while it's loading.

Is there a standard way of keeping high scores globally - I wrote my own on the server but it seems like a standard method should be available.

Thanks for looking


Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 260
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.

    What a palava!
    I agree. Here's the link:
    subject: jar files?
    It's not a secret anymore!