This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

JMH Harris

Greenhorn
+ Follow
since Nov 12, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by JMH Harris

Does anyone know where I can download the Java source code for HFJ? I am unable to locate this source at www.HeadFirstJava.com.

Thanks,
John
13 years ago
Thanks Nicholas & Marc for the suggestion to use "main"! Here's what the new code looks like:

import java.awt.*;

import java.awt.event.*;

class Party {

public static void main(String[] args){
//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);
} //more code here...
}

Guess what? Now the program runs without that previous "main" error! In fact I get no error messages at all! Great! But now the program just ends without producing that cute GUI with the two buttons. So are we saying the example on page 3 of "Head First Java" is in error for not including the "main" method and why am I not seeing the GUI so eloquently portrayed in the text?

Kind Regards,
John
13 years ago
Hello All,
Ok, this is my first time on the Forum, with my first book on Java, and my first Java question. A lot of firsts!
On page 3 of �Head First Java� the authors have a short program for the newbie to demonstrate all the neat aspects of Java. There is one problem; I am unable to get this program to work. The source will compile per the instructions in the book into byte code. But, when the byte code is executed I receive the following error message:

Exception in thread �main� java.lang.NoSuchMethodError: main

I am pretty sure the JDK & JRE are installed properly and the path variable is set correctly because the MyFirstApp application works as described on page 9 of �Head First Java�. So what am I missing?? Also, how does one display in a readable format the *.class file? I would like to be able to see the bytecode.

My future in Java programming is in the balance here!

Kind Regards,
John

P.S. Here�s the code:


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);
} //more code here...
}
13 years ago