Jump to content
  • Advertisement
Sign in to follow this  
yves032784

[java] need help, it's been a long time since i've used java

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It's been a while since i've coded anything in Java, so I need your help. I got this tutorial on applets at http://java.sun.com/docs/books/tutorial/applet/overview/index.html
import java.applet.Applet;
import java.awt.Graphics;

public class yves extends Applet {

    StringBuffer buffer;

    public void init() {
	buffer = new StringBuffer();
        addItem("initializing... ");
    }

    public void start() {
        addItem("starting... ");
    }

    public void stop() {
        addItem("stopping... ");
    }

    public void destroy() {
        addItem("preparing for unloading...");
    }

    void addItem(String newWord) {
        System.out.println(newWord);
        buffer.append(newWord);
        repaint();
    }

    public void paint(Graphics g) {
	//Draw a Rectangle around the applet's display area.
        g.drawRect(0, 0, size().width - 1, size().height - 1);

	//Draw the current string inside the rectangle.
        g.drawString(buffer.toString(), 5, 15);
    }
}
Tried that exact peice of code and got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: yves
Press any key to continue...
I'm using the latest version of the SDK

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by yves032784
It's been a while since i've coded anything in Java, so I need your help.

I got this tutorial on applets at http://java.sun.com/docs/books/tutorial/applet/overview/index.html
*** Source Snippet Removed ***
Tried that exact peice of code and got this error:

Exception in thread "main" java.lang.NoClassDefFoundError: yves
Press any key to continue...


I'm using the latest version of the SDK


Looks like you're trying to write an application (run from the command line) instead of an applet (which has to be embedded in a web page)

take a look at this trail first:
http://java.sun.com/docs/books/tutorial/getStarted/application/index.html

then to write GUI applications, the 'ole swing trail is the place to go:
http://java.sun.com/docs/books/tutorial/uiswing/index.html

D.

Share this post


Link to post
Share on other sites
Quote:
Original post by daireq
Looks like you're trying to write an application (run from the command line) instead of an applet (which has to be embedded in a web page)

Applets don't need to be in a webpage, I use applets all the time for simple sound managers...

Share this post


Link to post
Share on other sites
However, to run the class above the op (original poster) would have to either put it in a webpage or use appletviewer (as this is a newbie question I doubt if its an applet in an application...).

The error says to me either 1) the op isn't specifying the path correctly or 2) if it IS in a webpage then he may not have a 1.4+ version of the jre setup as the plugin.

Need more info op, how are you running the applet?

Share this post


Link to post
Share on other sites
Where is located the wrongly named yves.class? You should use capital leters for class names.

Try to write application first, browsers are BAD company.
Of course if you have set classpath to some value, you should have "-cp .", or is it "-cp.", in the command line.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!