Exception in thread "main" java.lang.NoClassDefFoundError: ClassName/class

I have the same problem too with java applications, I have a book examples (i don't know how it's named, coz i found them in internet alone, but all of them describe Swing GUI). When i compile and run them

javac JavaSource.java

java JavaClass (not .class)

i get the same erro. What can it be. For example thwe smallest example from this book is:

import java.awt.*;

import javax.swing.*;

import javax.swing.border.*;

public class OvalBorder implements Border

{

protected int m_w=6;

protected int m_h=6;

protected Color m_topColor = Color.white;

protected Color m_bottomColor = Color.gray;

public OvalBorder() {

m_w=6;

m_h=6;

}

public OvalBorder(int w, int h) {

m_w=w;

m_h=h;

}

public OvalBorder(int w, int h, Color topColor,

Color bottomColor) {

m_w=w;

m_h=h;

m_topColor = topColor;

m_bottomColor = bottomColor;

}

public Insets getBorderInsets(Component c) {

return new Insets(m_h, m_w, m_h, m_w);

}

public boolean isBorderOpaque() { return true; }

public void paintBorder(Component c, Graphics g,

int x, int y, int w, int h) {

w--;

h--;

g.setColor(m_topColor);

g.drawLine(x, y+h-m_h, x, y+m_h);

g.drawArc(x, y, 2*m_w, 2*m_h, 180, -90);

g.drawLine(x+m_w, y, x+w-m_w, y);

g.drawArc(x+w-2*m_w, y, 2*m_w, 2*m_h, 90, -90);

g.setColor(m_bottomColor);

g.drawLine(x+w, y+m_h, x+w, y+h-m_h);

g.drawArc(x+w-2*m_w, y+h-2*m_h, 2*m_w, 2*m_h, 0, -90);

g.drawLine(x+m_w, y+h, x+w-m_w, y+h);

g.drawArc(x, y+h-2*m_h, 2*m_w, 2*m_h, -90, -90);

}

public static void main(String[] args) {

JFrame frame = new JFrame("Custom Border: OvalBorder");

JLabel label = new JLabel("OvalBorder");

((JPanel) frame.getContentPane()).setBorder(new CompoundBorder(

new EmptyBorder(10,10,10,10), new OvalBorder(10,10)));

frame.getContentPane().add(label);

frame.setBounds(0,0,300,150);

frame.setVisible(true);

}

}

[2154 byte] By [SeaverDeath] at [2007-9-26 2:50:35]
# 1
include your current directory (.) in your classpathie at the prompt type set classpath=.;%classpath%Also if you compile JavaSource.java, you must run JavaSource by typingjava JavaSource I hope "java JavaClass" is a typo
shirish_wagh at 2007-6-29 10:37:14 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2

The 'java' command requires a single argument - the fully-qualified name of the class to execute. When you enter "java OvalBorder" java tries to find a file named OvalBorder.class. It searches in the directories in your system Classpath setting for the file. If it finds the file, it looks inside and checks to see if the class inside is OvalBorder. If it can't find the file or the class inside is something else, you get the error.

Class names are case sensitive. "Fully qualified class name" means, if your class is part of a package, the name is package_name.class_name, where package_name is the same as the package statement in the source code and matches with a directory path.

If you CD to the directory where you know the file OvalBorder.class exists, try using "java -classpath . OvalBorder. If this makes the NoClassDefFound:OvalBorder error go away, add . to your system classpath.

atmguy at 2007-6-29 10:37:14 > top of Java-index,Archived Forums,New To Java Technology Archive...