File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes First dumb question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "First dumb question" Watch "First dumb question" New topic
Author

First dumb question

Steve Janvrin
Greenhorn

Joined: Feb 10, 2005
Posts: 9
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: 8927
    
    9

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
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
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: First dumb question