OK.. I am going to try not to be a pest here. I am a newbie, so if I am being a pest I am very sorry...
Anyway.. I am trying to use the book Head First Java and it is giving me errors when I try to run it. It took me a while to get it to compile first. I did see that I was using the wrong case on some of the code that I was doing.. Now I see from other notes why.. Anyway..
import java.awt.*; import java.awt.event.*; class Party { public void buildinvite(){ Frame f = new Frame(); Label i = new Label("Party at tim's"); Button b = new Button("You Bet"); Button c = new Button("shoot me"); Panel p = new Panel(); p.add(i); } }
This works fine.. Now if I try to run it either in Javabeans IDE or with the SDK I get the same basic error of:
// at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:251) at java.net.URLClassLoader.access$100(URLClassLoader.java:55) at java.net.URLClassLoader$1.run(URLClassLoader.java:194) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:187) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) Exception in thread "main" // is only with an IDE that I am using..
With the SDK I get this: C:\>j2sdk1.4.2_04\bin\java.exe party Exception in thread "main" java.lang.NoClassDefFoundError: party
This is what I was told to do in the book..
What am I missing here.
Greg T Robertson
Ranch Hand
Joined: Nov 18, 2003
Posts: 91
posted
0
Isn't this the same as your other post? Other post - there is info in the other thread to help you
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
posted
0
In your posted code, the name of the class is Party, not party. So, if this class defines program (i.e. has a main method), you would run it with the command java Party, but the class in the posted code does not include a main method and so cannot be run as a program.