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 Maybe it's me. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Maybe it Watch "Maybe it New topic

Maybe it's me.

Patrick Roberts

Joined: May 25, 2011
Posts: 2
Hi all, I'm new here, and am trying to learn Java as my first programming language. using Head First Java 2nd Edition. Unfortunately I think I hit my head before studying. There is something I'm not getting. I'm not even sure if I'm supposed to be compiling and trying to run these codes yet. But my first one is the simple Doobee program. I have managed to get it to compile. But then I get an error when I try to run it.

Here is my code

Then here is the message I get after I compile it and try to run it

java Doobee
Exception in thread "main" java.lang.NoClassDefFoundError: Doobee
Caused by: java.lang.ClassNotFoundException: Doobee
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
Could not find the main class: Doobee. Program will exit.

I've compared my code to the book, and others. I can't find anything wrong. I'm wondering if I'm even supposed to be attempting to compile and run them at this point. Thanks for any help!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

Welcome to the Ranch, Patrick!

The error you're getting is a very common (perhaps the most common) error that beginners get. NoClassDefFoundError means that Java cannot find the class you're trying to run.

In your case, this most likely happens because your class is named DooBee, but on the command line you're calling it Doobee. Java is case-sensitive; according to Java, DooBee is not the same as Doobee. Try running it like this:

java DooBee

Other reasons why you could get this error is when your classpath is not set correctly. The classpath specifies where Java searches for *.class files. If you don't specify it, Java will by default look in the current directory for *.class files.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Patrick Roberts

Joined: May 25, 2011
Posts: 2
Thank you so much! I'm just going to outlaw capital letters I think... Now I just have to figure out that 99 bottles of beer.

And I just got that one to work woo!
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
I am afraid you can't outlaw capital letters; they are a standard part of Java™ naming styles.
I agree. Here's the link:
subject: Maybe it's me.
jQuery in Action, 3rd edition