title: Compiling Java Applets
body: <p>I recently started making a Java applet game for the java4k game contest but I'm new with applets and I have some questions about them.</p>
  
  <p>I have an applet written in eclipse and I can run it in eclipse using applet viewer but how do I compile it? There doesn't seem a option for compiling applets..</p>
  
  <p>..and what is a jar archive?</p>
  
  <p>Thanks.</p>
  
  <p>Also here's my source in case you need it:</p>
  
  <pre><code>import java.applet.*;
  import java.awt.*;
  import java.awt.event.*;
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.IOException;
  import java.util.*;
  
  import javax.imageio.ImageIO;
  public class game extends Applet implements KeyListener{
  
      private static final long serialVersionUID = 1L;
      public int x = 50,y = 50;
      public boolean right, left, down, up, lt = false, rt = true;
      public Image buffer;
      BufferedImage img = null;
      BufferedImage imgl = null;
      Graphics bg;
  
      public void init(){
          try {
              img = ImageIO.read(new File("C:/player.png"));
          } catch (IOException e){}
          try {
              imgl = ImageIO.read(new File("C:/playerl.png"));
          } catch (IOException e){}
          addKeyListener(this);
          setSize(400,200);
          setBackground(Color.cyan);
          Timer t = new Timer();
          t.schedule(new TimerTask(){public void run(){
                  if (right == true){x++;}
                  if (left == true){x--;}
                  if (up == true){y--;}
                  if (down == true){y++;}
                  repaint();
              }},10,10);
          buffer = createImage(400,200);
          bg = buffer.getGraphics();
      }
      public void paint(Graphics g){
          bg.setColor(Color.WHITE);
          //bg.clearRect(0, 0, 400, 200);
          if (rt == true){
              bg.drawImage(img,x,y, this);
          }
          if (lt == true){
              bg.drawImage(imgl,x,y, this);
          }
          g.drawImage(buffer,0,0,this);
      }
      public void keyTyped(KeyEvent e){}
      public void keyPressed(KeyEvent e){
          if (e.getKeyCode() == 37){
              left = true;
              lt = true;
              rt = false;
          }
          if (e.getKeyCode() == 39){
              right = true;
              rt = true;
              lt = false;
          }
          if (e.getKeyCode() == 38){
              up = true;
          }
          if (e.getKeyCode() == 40){
              down = true;
          }
      }
      public void keyReleased(KeyEvent e){
          if (e.getKeyCode() == 37){
              left = false;
          }
          if (e.getKeyCode() == 39){
              right = false;
          }
          if (e.getKeyCode() == 38){
              up = false;
          }
          if (e.getKeyCode() == 40){
              down = false;
          }
      }
      public void update(Graphics g){
          paint(g);
      }
  }
  </code></pre>