Hi,
 
 
           I m trying Circle.java programme in the tools directory & its workin fine ( compilation & running ). But whenever I m trying to add the following import statement Its giving me error That class could not be found though its compiling successfully.
 
       
package net.tinyos.tools;
import java.io.*;
import net.tinyos.packet.*;
import net.tinyos.util.*;
import net.tinyos.message.*;
 
                   When ever I m trying to add above packages its showing me NoclassDefFound exception.
 
                     So does it mean that these packages can not be imported by other Applet programme in the same folder ( tools ) ?
 
Note : I haven't used any of the classes from above package, but just imported them in my applet file.
 
Following is my simple applet programme imported with above packages which gives me error.
 
// What follows here is a special javadoc comment, which is
// used for automatic generation of documentation in HTML.
/**
* Simple applet of moving circle.
*
* @author Les Kitchen <[EMAIL PROTECTED]>
*
*
*/
// This is probabl! y a lot more heavily commented than necessary,
// for didactic purposes...
// Imported stuff for windowing, events, and applets...
 
package net.tinyos.tools;
import java.io.*;
import net.tinyos.packet.*;
import net.tinyos.util.*;
import net.tinyos.message.*;
 
 
 
 
 
 
 
 
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
// Comment-embedded sample HTML code for invoking this applet
// So that the source code can be fed to appletviewer
// In the applet HTML tag, code is the .class file where the
// Java bytecode can be found, as a URL (in this case a relative URL),
// and width and height give the width and height of the applet.
// The param tags pass parameters to the applet (only one here).
/*
<applet code="Circle" width=300 height=200>
<param name=sleeptime value=100>
</applet>
*/
 
// This is a specialization of the Java Applet class, and it has
// to implement the KeyListener, MouseListener and Runnable interfaces
// so it can respectively handle key events, handle mouse events, and be
// run as a thread.
public class Circle extends Applet
implements KeyListener, MouseListener, Runnable {
// Encodings of directions -- "final" so they're in effect constants
// Even numbers so diagonal directions could be added later
// Multiples of 45 degrees anticlockwise from East
final int E = 0; // East
final int N = 2; // North
final int W = 4; // West
final int ! S = 6; // South
// Various bits of information for our applet's state
int direction = E; // movement direction
int cx = 10, cy = 10; // circle center
int diameter = 20; // circle diameter
Thread t = null; // Thread for moving the circle
boolean running = false; // Whether thread is running
// How long to sleep between circle movements, milliseconds.
int sleeptime = 100;
 
// The next four methods, init(), start(), stop(), and paint(),
// are part of Applet. We override them here to do what we want.
// There's also a destroy() method, but we don't need to worry about
// it.
// Called from outside when the applet is first created
public void init() {
System.out.println("This is in init ");
// Grab (as a string) the parameter named "sleeptime"
! // from the HTML applet's param tag
String sleepstring = getParameter("sleeptime");
// The sleeptime parameter may not have been provided
// (note null object not empty string), or may have been
// badly formatted, triggering a caught exception. In
// either case, stick with default.
try {
if( sleepstring != null ) {
sleeptime = Integer.parseInt(sleepstring); // Like atoi() in C
}
} catch(NumberFormatException e) {
// Do nothing if badly formatted number triggers exception
}
// Nominate this applet itself as the listener for key and mouse
// events.
addKeyListener(this);
addMouseListener(this);
requestFocus(); // Request input focus -- needed to get input at all
// Background color for the applet's window
setBackground(Color.WHITE);
}
// Called from outside whenever applet starts running -- whenever it
// becomes visible
public void start () {
System.out.println("This is in start ");
// All we do is create a new thread to run the run() method
// of this applet, and set it going.
t = new Thread(this);
running = true;
t.start();
}
// Called from outside whenever applet stops running -- whenever it
// becomes invisible. So we don't have to waste CPU cycles updating
// the graphics display unnecessarily.
public void stop () {
System.out.println("This is in stop ");
// All we do is mark that the thread should stop running,
// to be noticed by the run() method next time it wakes up.
running = false;
// Not strictly necessary, but if we no longer keep a reference
/! / to the thread, then it can get garbage collected sooner.
t = null;
}
// Called from outside whenever the applet should have its
// window display redrawn.
public void paint(Graphics g) {
System.out.println("This is in paint ");
// Gets passed the Graphics object on which to draw.
// All we do is pass it on to our own method.
g.setColor(Color.BLACK);
drawCircle(g, cx, cy, diameter );
}
 
// This is the one method required to implement the Runnable interface.
// It's called by a thread to do our work. This is the heart of
// the applet's action.
public void run () {
System.out.println("This is in run ");
// We loop (almost) forever, repainting, sleeping a bit, and
// calling our own method move() to change the posi! tion of
// the circle. The thread terminates when running gets set
// to false (presumably by stop()), so we have to keep polling that.
for(;;) {
try {
// This is the preferred way for an applet to ask for
// its window to be redrawn. Calling paint() directly
// would holdup execution while the (possibly lengthy)
// paint() method completed. Calling repaint() just
// tells the system to schedule a call to paint()
// sometime real soon now.
repaint();
if(!running) break;
Thread.sleep(sleeptime);
move();
} catch (InterruptedException e) {
// The thread might get interrupted. We have to
// catch that exception just to do nothing about it.
}
}
}
 
 
// The next three methods have to be here so our appl! et implements
// the KeyListener interface.
// Called from outside whenever a key is depressed.
public void keyPressed(KeyEvent ke) {
// Basically, get the key code from the event object passed in
// and do various things, like change size of the circle for
// PAGE_UP PAGE_DOWN, or change direction of motion for arrow
// keys. Note this just changes the internal parameters of
// the applet; the movement of the circle, and the drawing
// happens elsewhere.
int key = ke.getKeyCode();
switch(key) {
case KeyEvent.VK_PAGE_DOWN:
if( diameter > 1 ) --diameter;
break;
case KeyEvent.VK_PAGE_UP:
diameter++;
break;
case KeyEvent.VK_LEFT:
direction = W;
break;
case KeyEvent.VK_RIGHT:
direction = E;
break;
case KeyEvent.VK_UP: