Hello. I haven't done much Java programming for a few years and have recently installed the Java 6 SDK. I cant seem to figure out how to fix this problem though. It works fine under Java 5. Here is the error.
C:\Program Files\Java\jdk1.6.0_16\bin>java "z:\java_stuff\SwingExample.class" Exception in thread "main" java.lang.NoClassDefFoundError: z:\java_stuff\SwingEx ample/class Caused by: java.lang.ClassNotFoundException: z:\java_stuff\SwingExample.class at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Could not find the main class: z:\java_stuff\SwingExample.class. Program will e xit.
Here is the actual Java code. Just a simple JFrame example.
import java.awt.*; import javax.swing.*; /** * Basic Swing example. */ public class SwingExample { public static void main(String[] args) { // Create a JFrame, which is a Window with "decorations", // i.e. title, border and close-button JFrame f = new JFrame("Swing Example Window"); // Set a simple Layout Manager that arranges the Components f.setLayout(new FlowLayout()); // Add a label f.add(new JLabel("Hello world!")); // "Pack" the window, making it "just big enough". f.pack(); // Set the default close operation for the window, // or else the program won't exit when clicking close button f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // Set the visibility as true, thereby displaying it f.setVisible(true); } }
Any insight would be greatly appreciated. Thank you.
Edit: Forgot to mention but it compiles just fine and the class and filename match.
Edit: Finally found the problem.