aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Maybe it Watch "Maybe it New topic
Author

Maybe it's me.

Patrick Roberts
Greenhorn

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 java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
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: 14269
    
  21

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
Greenhorn

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
Sheriff

Joined: Oct 13, 2005
Posts: 39408
    
  28
I am afraid you can't outlaw capital letters; they are a standard part of Java™ naming styles.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maybe it's me.