File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread"main"java.lang.NoSuchMethodError.main" Watch "Exception in thread"main"java.lang.NoSuchMethodError.main" New topic

Exception in thread"main"java.lang.NoSuchMethodError.main

Deborah Gooch

Joined: Nov 11, 2010
Posts: 6
I do not know why I am getting the above error.

Here is the file created and saved as

It compiled into a class but when I try to run it I get the message on the subject line and don't know why. I am new at this and learning from the book "Head First Java - 2nd Edition.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3152

How did you compile and run the program?

Mohamed Sanaulla | My Blog
Deborah Gooch

Joined: Nov 11, 2010
Posts: 6
I ran javac from the command prompt and once it compiled it into a .class

I ran java BeerSong

Deborah Gooch

Joined: Nov 11, 2010
Posts: 6
Okay I finally figured it out. When I first compiled it there were errors. I corrected them an resaved the original file but did not delete and recompile it. I just now did it and it worked. Sorry.

Can I ask what the difference is between Java and JavaScript in this forum?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

They are two completely different languages. Javascript is a client-side language that runs in your browser.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

I once saw a comic which explained the difference between Java and JavaScript with the question: What is the difference between ham and hamster?

The only reason that the word "Java" is also in the name of the language JavaScript is because Netscape and Sun in 1997 thought that Java was a cool name, and for marketing reasons they decided upon that name - but JavaScript really has nothing to do with Java.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
sean parsons
Ranch Hand

Joined: Oct 18, 2010
Posts: 34
Nice we are reading the same book, i did that exercise the other day i am now on the battle shit exercise but i decided to try to make my own code from scratch made me learn alot more than just looking at the book and copying.

Wants to change the world....
I agree. Here's the link:
subject: Exception in thread"main"java.lang.NoSuchMethodError.main
It's not a secret anymore!