Results 1 to 5 of 5
- 08-18-2011, 11:48 PM #1
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
problems with swing example program
Im writing a simple gui program i found in the java complete reference book. the code as far as i can tell is a carbon copy of whats found in the book. however i always get a runtime error when i run it.
The code:
package swing1;
import javax.swing.*;
class SwingDemo {
SwingDemo() {JFrame jfrm = new JFrame("a simple swing application");
jfrm.setSize(275, 100);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
JLabel jlab = new JLabel("Swing means powerful GUIs");
jfrm.add(jlab);
jfrm.setVisible(true);}
public static void main(String args[]) {
SwingUtilities.invokeLater(new Runnable() {
public void run() { new SwingDemo();
}
});
}
}
the error:
Exception in thread "main" java.lang.NoClassDefFoundError: swing1/Main
Caused by: java.lang.ClassNotFoundException: swing1.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
Java Result: 1
any ideas of what is causing this error?
thanks
- 08-19-2011, 12:11 AM #2
How are you running the program? If it is on the command line then post the command you use and your working directory.
- 08-19-2011, 12:17 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
ive been running it using netbeans would you suggest running it on the command line?
- 08-19-2011, 12:21 AM #4
You need to modify Netbeans run command. It is trying to run a class called Main but your class is called SwingDemo.
- 08-19-2011, 12:23 AM #5
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Swing Problems
By niba10 in forum Advanced JavaReplies: 5Last Post: 02-25-2011, 02:18 PM -
Simple swing program, help please!
By N00Bie in forum New To JavaReplies: 5Last Post: 02-17-2011, 05:16 PM -
Package layout problems trying to make a new Swing component.
By TheShagg in forum AWT / SwingReplies: 13Last Post: 12-06-2010, 05:57 AM -
need help in uploading images in swing program!!!
By ashton in forum New To JavaReplies: 10Last Post: 01-26-2009, 10:01 AM -
netbeans+swing = painting program?
By yuriythebest in forum New To JavaReplies: 3Last Post: 12-14-2008, 08:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks