Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Will compile, but will not run?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Will compile, but will not run??

Steven Pierce

Joined: May 27, 2004
Posts: 6
Good Afternoon,

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();

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:

java.lang.NoClassDefFoundError: lib/party (wrong name: Party) ** I get this with the SDK also. **

// at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
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
Isn't this the same as your other post? Other post - there is info in the other thread to help you
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
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.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Closing this thread. Please continue in the duplicate.
I agree. Here's the link:
subject: Will compile, but will not run??
It's not a secret anymore!