Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

No ClassDefFoundError Again  RSS feed

 
Glen Scheel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Below is a short program that I beleive I have transcribed correctly. It is just intended as an introduction to simple GUI programming. It compiles fine but when I try to run it I get "Exception in thread "main" java.lang.NoClassDefFoundError: demoFlowLayout
import javax.swing.*;
import java.awt.*;
public class demoFlowLayout extends JFrame{

private JButton one, two, three;
private Container container;
public demoFlowLayout()
{
super("Demo Flow Layout");
container=getContentPane();
container.setLayout(new FlowLayout());
one=new JButton("one");
two=new JButton("two");
three=new JButton("three");
container.add(one);
container.add(two);
container.add(three);
setSize(200,100);
setVisible(true);
}
public static void main(String args[])
{
demoFlowLayout application = new demoFlowLayout();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
I'm sure that I've made a simple error, but I just can't see it.
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem has nothing to do with the source code itself. When you compile this it will create a "demoFlowLayout.class" file. To run it, make sure that the classpath contains the directory of where the class file exists. If you CD to the directory, it could be:
java -cp "." demoFlowLayout
[ November 21, 2003: Message edited by: Wayne L Johnson ]
 
Glen Scheel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, got it. Looks like fixing my last problem created this one.
Many thanks for the quick response.
Glen
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!