Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Can't find itself Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic

Can't find itself

Sarah Mooney

Joined: Feb 22, 2002
Posts: 3
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.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???
Sal Velinus

Joined: Mar 05, 2002
Posts: 25
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

Joined: Feb 22, 2002
Posts: 3
Thanks, it was a ClassPath error.
So simple but it was driving me nuts!
I agree. Here's the link:
subject: Can't find itself
It's not a secret anymore!