Combining Jar Files

This shows how we manipulate jar files using the jar program that is part of the Java JDK. To see the applets in action visit the web page here, enable Java and view the Console. Move the cursor just under the "Back Buffer Demo" title to view the middle applet.

See below (1) the code of our batch file used to process the jar files, (2) the HTML file used to display three applets and (3) a screenshot. The jar program can take several single character parameters passed on the command line or in a batch file. The characters x, v, f and c represent extract, verbose, file and create, respectively.

Batch file code

jar xvf threads.jar threads/ThreadApplet.class
jar xvf back_buffer.jar back_buffer/BackBufferApplet.class
jar xvf draw.jar draw/DrawApplet.class
jar cvf demo.jar back_buffer/BackBufferApplet.class threads/ThreadApplet.class 

Web page showing three applets from one jar file

<html xmlns="">
    <title>Applet Demonstrations</title>
      <h3>Draw Demo</h2>   
      <p>Java must be enabled.</p> 
          <td><h4 align="center">Draw Demo</h4> 
                 <applet archive="demo.jar" code="draw/DrawApplet.class" 
                      width="300" height="300" /> </td>
           <td><h4 align="center">Back Buffer Demo</h4>  
                  <applet archive="demo.jar" code="back_buffer/BackBufferApplet.class" 
                       width="200" height="200" /></td>
            <td><h4 align="center">Thread Demo</h4> 
                   <applet archive="demo.jar" code="threads/ThreadApplet.class" 
                         width="200" height="200" /></td>


Screenshot showing output

Screenshot showing graphical and text output

Programming - a skill for life!

Mouse and keyboard input, graphics (including Graphics2D), threads and widgets in Oxygene for Java applets