This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud and have Kyle Brown, Bobby Woolf and Joseph Yodor on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Sams Java in 21 Days java.lang.NoClassDefFoundError: main

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




With the above code, I get the error:


I thought maybe it was the way eclipse was using my file structure as a package, so I eliminated that by removing the custom package line and compiling and running them on my desktop. They compile into classes fine, it's just when actually trying
to run them, it won't work. I'm stumped, the book doesn't give me an answer, and I can't really progress further without fixing this or at least knowing why it's happening so it doesn't happen again in the future.

Any help would be most appreciated.

-P
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java is case sensitive. The method should be called main, not Main.
 
Patches O'Connell
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Java is case sensitive. The method should be called main, not Main.



Fixed that problem, so I tried again. It still does the same thing.

I decided to just delete Java and reinstall it. After doing so, the error message is a little longer, but essentially the same.

Here it is.



Now what do I do? :<

I'm completely lost, and this is seriously turning me off Java.
 
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What did you do to make it look for a class named "main"? Your class is named "VolcanoApplication", so that's what you need to run.
 
Patches O'Connell
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure, this is a verbatim copy of the code that "Sams Learn Java in 21 Days" said to write. I'm literally day 1, so I haven't really done anything besides what it told me.
 
Paul Clapham
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wasn't asking about the code. I was asking about what you did to cause that error message to show up on your screen.

(By the way: a lot of Java beginners seem to be sensitive about error messages. It's as if error messages were some kind of a put-down telling you that you were a bad or worthless person, or something like that. And it can actually feel that way if you keep getting error messages all the time. But it's not supposed to be like that. Remember the computer isn't your instructor or your mother or the police, it's just a machine which is working for you. So there's nothing personal about error messages; when you get one, read it, because it's supposed to tell you what went wrong. And I can tell you that you're going to get lots more error messages. That's just the way it is when you're a programmer. Read them, deal with them, and move on.)
 
Patches O'Connell
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I wasn't asking about the code. I was asking about what you did to cause that error message to show up on your screen.

(By the way: a lot of Java beginners seem to be sensitive about error messages. It's as if error messages were some kind of a put-down telling you that you were a bad or worthless person, or something like that. And it can actually feel that way if you keep getting error messages all the time. But it's not supposed to be like that. Remember the computer isn't your instructor or your mother or the police, it's just a machine which is working for you. So there's nothing personal about error messages; when you get one, read it, because it's supposed to tell you what went wrong. And I can tell you that you're going to get lots more error messages. That's just the way it is when you're a programmer. Read them, deal with them, and move on.)



Oh, don't worry. I program Perl and Python, so I know error messages aren't the end of the world, but I've been running into error after error since I started the java, and it's only the first snippet of code. So yeah, programming isn't new to me (Perl for like 8 years), but Java very much so is, so naturally it brings me to frustration easier because I've no idea how to fix the error when in one of my native languages it would be trivial. Not to mention I've had a bad day with Github and its many annoyances over the past couple days :P

The way I'm triggering this message is with two methods: First, Eclipse->Run. Second, with the main Java executable. java VolcanoApplication.class
 
Patches O'Connell
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made headway. I'm not sure how this fix worked, but I figured...hey...why not. Maybe some one can explain to me why this worked in the first place, and if I'll have to do it exactly like this for every project.
It works now though, which is nice. Picture incoming. Sorry for it being so large, but it doesn't scale with the img tag.

 
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please avoid screenshots; they are more difficult to read than copy-and-paste.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Patches O'Connell wrote:I made headway...


Great. Slightly off-subject: I'd be suspicious of any book that calls itself "Java in 21" anything (except maybe 'years'). This page backs me up.

Winston
 
Campbell Ritchie
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a copy of a SAMS Java™ in 21 days book, and I don’t like it.

And compiler errors are your friend. They are a way of picking up mistakes at an early stage, before they have a chance to do any harm.
 
reply
    Bookmark Topic Watch Topic
  • New Topic