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

## 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();
}

public void start() {
}

public void stop() {
}

public void destroy() {
}

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...

##### Share on other sites
Quote:
 Original post by yves032784It'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: yvesPress 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 on other sites
Quote:
 Original post by daireqLooks 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 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.

##### 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.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628356
• Total Posts
2982253

• 10
• 9
• 13
• 24
• 11