Forums Register Login

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

+Pie Number of slices to send: Send




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
+Pie Number of slices to send: Send
Java is case sensitive. The method should be called main, not Main.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.)
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
Please avoid screenshots; they are more difficult to read than copy-and-paste.
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
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.
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1548 times.
Similar Threads
Error when using package
Unsupported major.minor version 49.0
symbol error...HELP!
Some Simple(??) Java problems.
Netbeans 7.0.1 questions
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:25:40.