Author
First dumb question
Steve Janvrin
Greenhorn
Joined: Feb 10, 2005
Posts: 9
posted Feb 10, 2005 09:57:00
0
I just started using the Head First Java book to learn Java. I created my source file using the code from page 7. It is: public class MyFirstApp { public static void main (String [] args) { System.out.println ("I Rule!"); System.out.println ("The World"); } } I don't see any errors, but I get the following when I attempt to run it: Exception in thread "main" java.lang.NoClassDefFoundError : MyFirstApp Please advise. Also - am I in the right place for questions this basic? Steve Janvrin.
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
Welcome to the Java Ranch. So many people have this problem, it made the FAQ . And yes, you are in the right place to ask the most very basic questions. Good Luck!
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch ]
K Riaz
Ranch Hand
Joined: Jan 08, 2005
Posts: 375
posted Feb 10, 2005 10:11:00
0
try java -cp . MyFirstApp
Matt Fielder
Ranch Hand
Joined: Oct 27, 2004
Posts: 158
what did you save the file as?
Steve Janvrin
Greenhorn
Joined: Feb 10, 2005
Posts: 9
posted Feb 10, 2005 11:10:00
0
I saved the file as .java. I'll try the suggestions and post again if I still have problems. Thanks for the quick replies. Steve.
Matt Fielder
Ranch Hand
Joined: Oct 27, 2004
Posts: 158
sorry I should have typed more. One of my early mistakes was that I didn't know that the file name and class name had to be the same.
Steve Janvrin
Greenhorn
Joined: Feb 10, 2005
Posts: 9
posted Feb 10, 2005 12:52:00
0
Matt - thanks for the clarification. I did indeed have the name of the file and the class name as the same thing. I got the program to run successfully using Kashif's approach. Thanks again for the help. Steve.
subject: First dumb question