Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Deborah Gooch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know why I am getting the above error.

Here is the file created and saved as BeerSong.java

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
Posts: 3165
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you compile and run the program?
 
Deborah Gooch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran javac BeerSong.java from the command prompt and once it compiled it into a .class

I ran java BeerSong

 
Deborah Gooch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are two completely different languages. Javascript is a client-side language that runs in your browser.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15632
46
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sean parsons
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic