Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't find itself

 
Sarah Mooney
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing the following simple program:
import javax.swing.*;
import java.awt.*;
public class TryWindow{
//the window object
private static JFrame aWindow = new JFrame("This is the Window Title");
public static void main(String[] args){
Toolkit theKit = (Toolkit)aWindow.getToolkit();//Get the window toolkit
Dimension wndSize = (Dimension)theKit.getScreenSize(); //Get screen size
aWindow.setBounds(wndSize.width/4, wndSize.height/4,
wndSize.width/2, wndSize.height/2); //Set position and size
aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
aWindow.getContentPane().setBackground(Color.pink);
aWindow.setVisible(true); //Display the window
}
}

I am getting a:
Exception in thread "main" java.lang.NoClassDefFoundError: TryWindow
Someone else in my shop is running it just fine. Am I missing something on my computer???
Thanks
 
Sal Velinus
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't learned much about windows, either applets or guis, but when I get that error it's usually either an incorrect classpath, or compiling from the wrong directory.
This might sound dumb, but did you name the file TryWindow as well as the class?
 
Sarah Mooney
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it was a ClassPath error.
So simple but it was driving me nuts!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic