File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Can't find itself

Sarah Mooney
Greenhorn

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

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
Greenhorn

Joined: Feb 22, 2002
Posts: 3
Thanks, it was a ClassPath error.
So simple but it was driving me nuts!
 
GeeCON Prague 2014
 
subject: Can't find itself