Thread getting NoClassDefFoundError


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Thread getting NoClassDefFoundError

Hybrid View

  1. #1
    CJ Guest

    Thread getting NoClassDefFoundError


    OK, I'm trying to learn this thread stuff and ran into a little problem. I
    don't know if it is my understanding, code, or a combination.

    Here is what is going on....

    I have an applet that runs fine. I wanted to add a thread to that applet
    to run a marquee across the bottom (South). I set up a MarqueeCanvas class
    to hold the message, then added a thread to start the marquee running. I
    instantiate the Canvas first in the applet. Then instantiate the thread passing
    in the Canvas object. In the Thread code I instantiate a canvas object as
    well, and copy the object passed in into this instance (so that I don't loose
    the object)....then when I get back to the applet I "start" the thread, but
    I get the famous NoClassDefFoundError:MarqueeCanvas. I don't understand.
    I thought that Java passed by reference and if I created an object in my
    applet and then passed that object to my Thread - my thread should then have
    the address of the object and be able to reference it, right?

    here are snippits of the code:

    Applet code - (dots indicate missing code)

    ...
    MarqueeCanvas marqueeCanvas = new MarqueeCanvas(
    "Welcome to My Movie Rater! Hope you enjoy!!!");
    MarqueeThread marqueeThread = new MarqueeThread(marqueeCanvas);

    public void init (){
    ...

    getContentPane().add("South", marqueeCanvas);
    System.out.println("Starting Marquee Thread!");
    marqueeThread.start();
    setMovieVector("general.movies");
    ...
    }

    MarqueeCanvas code -
    public class MarqueeCanvas extends Canvas{
    ...
    public MarqueeCanvas (String s) {
    message = s;
    System.out.println("message = " + message);
    }

    public void decrementPosition() {
    if (position + messageWidth < 0){
    position = initialPosition;
    }
    else
    {
    position = position - delta;
    }
    repaint();
    }
    ...
    }

    MarqueeThread -

    import java.lang.*;
    import java.io.*;

    public class MarqueeThread extends Thread{
    MarqueeCanvas canvas;

    public MarqueeThread (MarqueeCanvas c) {
    canvas = c;
    System.out.println("Marquee Canvas created in Marquee Thread!");
    }

    public void run(){
    while (true){
    canvas.decrementPosition();
    try{
    sleep(200);
    }
    catch (InterruptedException e) {
    return;
    }}}}

    Any ideas? I'm really stumped and need help to get this working please?

    TIA,

    cj


  2. #2
    Paul Clapham Guest

    Re: Thread getting NoClassDefFoundError


    CJ <cjboales@yahoo.com> wrote in message news:39f869b0$1@news.devx.com...
    >
    > OK, I'm trying to learn this thread stuff and ran into a little problem. I
    > don't know if it is my understanding, code, or a combination.
    >
    > Here is what is going on....


    Didn't I see this cross-posted in several other groups? Guess I'll assume
    that somebody else answered it there, then.




  3. #3
    CJ Guest

    Re: Thread getting NoClassDefFoundError


    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >
    >CJ <cjboales@yahoo.com> wrote in message news:39f869b0$1@news.devx.com...
    >>
    >> OK, I'm trying to learn this thread stuff and ran into a little problem.

    I
    >> don't know if it is my understanding, code, or a combination.
    >>
    >> Here is what is going on....

    >
    >Didn't I see this cross-posted in several other groups? Guess I'll assume
    >that somebody else answered it there, then.
    >
    >
    >


    Actually I did post on another forum...and did receive a reply. The problem
    was in the CLASSPATH. For some reason when I added the Thread code I had
    to go down further than just the directory where the code resided to get
    the applet to run without the error. Once I added the entire directory structure
    WITH THE MARQUEECANVAS CLASS included...the applet ran with no problems at
    all.

    Thanks for your response...

    cj


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center