title: Jimi(java): Noclassdeffound exception upon Jimi.createJimiWriter
body: <p>I hesitated to ask this, but i have spent numerous hours messing with environmental variables, I just cannot figure this out:</p>
  
  <p>I am trying to save whatever is displayed on an applet into an image file, after some research i thought JIMI was my best bet
  (below is not my original work, but a simple example from <a href="http://www.coderanch.com/t/337338/GUI/java/save-applet-image-gif-jpeg" rel="nofollow">http://www.coderanch.com/t/337338/GUI/java/save-applet-image-gif-jpeg</a> as to what i will be doing)</p>
  
  <pre><code>import java.applet.Applet;
  import java.awt.BorderLayout;
  import java.awt.Button;
  import java.awt.Canvas;
  import java.awt.Color;
  import java.awt.Graphics;
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.Image;
  import java.awt.Panel;
  import java.awt.Point;
  import java.awt.TextField;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.MouseEvent;
  import java.awt.event.MouseMotionListener;
  import java.awt.image.ColorModel;
  import java.awt.image.PixelGrabber;
  import java.io.OutputStream;
  import java.util.Vector;
  
  import com.sun.jimi.core.Jimi;
  import com.sun.jimi.core.JimiWriter;
  
  public class JimiApplet extends Applet implements ActionListener {
  
      private ImageCanvas canvas;
      private TextField filename;
      private Button save, clear;
  
      public void init() {
          setLayout( new BorderLayout() );
          canvas = new ImageCanvas();
          add( canvas, BorderLayout.CENTER );
          Panel p = new Panel();
          filename = new TextField();
          save = new Button( "Save" );
          save.addActionListener( this );
          clear = new Button( "Clear" );
          clear.addActionListener( this );
          p.setLayout( new GridBagLayout() );
          GridBagConstraints c = new GridBagConstraints();
          c.fill = GridBagConstraints.HORIZONTAL;
          c.weightx = .70;
          p.add( filename, c );
          c.weightx = .15;
          p.add( save, c );
          c.weightx = .15;
          p.add( clear, c );
          add( p, BorderLayout.SOUTH );
      }
  
      public void actionPerformed(ActionEvent e) { 
          if ( e.getSource() == save ) {
              save.setEnabled( false );
              filename.setEnabled( false );
              filename.setEditable( false );
              Thread t = new Thread( new SaveButtonPressed() );
              t.start();
          } else if ( e.getSource() == clear ) {
              canvas.clear();
          }
      }
  
      private static class ImageCanvas extends Canvas implements MouseMotionListener {
          private Vector points;
  
          public ImageCanvas() {
              points = new Vector();
              addMouseMotionListener( this );
          }
  
          public void mouseDragged(MouseEvent e) {
              Point p = e.getPoint();
              points.add( p );
              repaint();
          }
  
          public void mouseMoved(MouseEvent e) {
          }
  
          public void clear() {
              points.removeAllElements();
              repaint();
          }
  
          public void paint( Graphics g ) {
              int size = points.size();
              g.setColor( Color.black );
              if ( size &gt; 0 ) {
                  Point p1 = (Point)points.get( 0 );
                  for ( int i = 0; i &lt; size; i++ ) {
                      Point p2 = (Point)points.get( i );
                      g.drawLine( p1.x, p1.y, p2.x, p2.y );
                      p1 = p2;
                  }
              }
          }
      }
  
      private class SaveButtonPressed implements Runnable {
          public void run() {
              Thread t = new Thread( new SaveRunnable() );
              t.start();
              try {
                  t.join();
              } catch( InterruptedException x ) { 
                  x.printStackTrace();
              }
              finally {
                  save.setEnabled( true );
                  filename.setEnabled( true );
                  filename.setEditable( true );
              }
          }
  
      }
  
      private class SaveRunnable implements Runnable {
          public void run() {
              int width = canvas.getSize().width;
              int height = canvas.getSize().height;
              ColorModel cm = canvas.getColorModel();
              int[] pixels = new int[ width * height ];
              Image image = canvas.createImage( width, height );
              Graphics g = image.getGraphics();
              canvas.paint( g );
              PixelGrabber pg = new PixelGrabber( image, 0, 0, width, height, pixels, 0, width );
              boolean success = false;
              try {
                  success = pg.grabPixels();
              }
              catch (InterruptedException e2) {
                  e2.printStackTrace();
                  return;
              }
              if ( success ) {
                  String mimeType = "invalid";
                  String extension = filename.getText();
                  int index = extension.indexOf( '.' );
                  extension = extension.substring( index +1);
                  System.out.println(extension);
                  if ( extension.equalsIgnoreCase( "GIF" ) ) {
                      mimeType = "/image/gif";
                  } else if ( extension.equalsIgnoreCase( "JPG" )  ||
                          extension.equalsIgnoreCase( "JPEG" ) ) {
                      mimeType = "image/jpeg";
                  } else if ( extension.equalsIgnoreCase( "PNG" ) ) {
                      mimeType = "image/png";
                  }
  
                  // You can add more options here for the different image types 
                  // you want to support.
  
                  if ( mimeType.equals( "invalid" ) ) {
                      System.err.println( "Could not get a valid mime type from file extension!" );
                      return;
                  } else {
                      try {
                          OutputStream imageOutput = null;
  
                          // Do something here to get an OutputStream pointing to the socket, 
                          // URL of servlet, etc. that you are going to write your image to.
                          System.out.println("got here " + mimeType);
                          JimiWriter writer = Jimi.createJimiWriter( mimeType );
                          System.out.println("probably not here");
                          writer.setSource( image );
                          writer.putImage( imageOutput );
                      } catch ( Exception x ) {
                          x.printStackTrace();
                          return;
                      }
                  }
              } else {
                  System.err.println( "PixelGrabber failed!" );
              }
          }
  
      }
  }
  </code></pre>
  
  <p>I can compile this code with JIMI in my environmental variables. However, upon trying to save the image I get the error:</p>
  
  <pre><code> Exception in thread "Thread-5" java.lang.NoClassDefFoundError: com/sun/jimi/core/Jimi
             at JimiApplet$SaveRunnable.run(JimiApplet.java:165)
             at java.lang.Thread.run(Thread.java:662)
   Caused by: java.lang.ClassNotFoundException: com.sun.jimi.core.Jimi
              at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:211)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
              at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:144)
              at java.land.ClassLoader.loadClass(ClassLoader.java:247)
              ... 2 more
  </code></pre>
  
  <p>After research i found that this is mostly likly caused by not having jimiproclasses in my environmental variables, so i tried to add them doing numerous combinations, took me an hour an a half to do all combinations i thought would work
  In CLASSPATH AND in PATH, here are a few things i tried:</p>
  
  <pre><code>    C:\Users\dfreelan\Dropbox\colormap\Jimi;
      C:\Users\dfreelan\Dropbox\colormap\Jimi\JimiProClasses.zip;
      C:\Users\dfreelan\Dropbox\colormap\Jimi;C:\Users\dfreelan\Dropbox\colormap\Jimi\JimiProClasses.zip;
      C:\Users\dfreelan\Dropbox\colormap\Jimi\src\classes
  </code></pre>
  
  <p>I have tried more combinations, but i believe you can get the gist here
  With each of the examples above, i can compile (which shows that some form of Jimi is working) i just simply cannot do Jimi.createJimiWriter without receiving error in runtime</p>
  
  <p>Anybody's help is greatly appreciated. I am sorry if this seems a nooby question, but I have worked on it so long and i attacked it so meticulously i felt i had no place left to turn!</p>