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 same error when using XP and Eclipse to run program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "same error when using XP and Eclipse to run program" Watch "same error when using XP and Eclipse to run program" New topic

same error when using XP and Eclipse to run program

Derek B Smith

Joined: Oct 08, 2006
Posts: 9

I am using Eclipse IDE to practice Java 5 coding as well as the DOS command line. I am referencing HeadFirst Java for practice and the code error I cannot fix is this from the command line and from within Eclipse IDE:
Any help please?

thank you

From Eclipse:
java.lang.NoClassDefFoundError: DooBee
Exception in thread "main"

From DOS:

C:\temp>java DooBee
Exception in thread "main" java.lang.NoClassDefFoundError: DooBee

Here is my test code:

public class DooBee {
public static void main (String[] args) {
int x = 1;
while (x < 3) {
x += 1;

if (x == 3) {
} // end if
} // end main
} // end class

Here are my ENV variable:

C:\temp>echo %PATH%
C:\Perl\bin\;C:\ClarifyCRM12.0\Configurator\Common Files\CCAutomation;C:\ClarifyCRM12.0\Clarif
yClient;C:\Program Files\Compaq\Compaq Management Agents\Dmi\Win32\bin;C:\WINDOWS\system32;C:\
WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IBM\Client Access;C:\Program Files\IBM\Clien
t Access\Shared;C:\Program Files\IBM\Client Access\Emulator;C:\Program Files\ShowCase STRATEGY
\bin;C:\WINDOWS\system32\nls;C:\WINDOWS\system32\nls\ENGLISH;C:\MSSQL7\BINN;C:\Program Files\M
icrosoft SQL Server\80\Tools\BINN;c:\progra~1\VIAVOI~1;C:\Sun\AppServer\jdk\bin\;C:\Sun\AppSer
ver\bin;C:\Program Files\websm\bin;C:\eclipse;C\Perl\bin;

C:\temp>echo %CLASSPATH%

C:\temp>echo %JRE_LIB%
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11957

i'm assuming you're getting a class file. from the directory where that class file is (probably you're c:/temp), do this:

java -cp . DooBee

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15101

C:\temp>echo %CLASSPATH%

You don't have the current directory (".") in your classpath. When you try to run a Java program from the command line, Java will search for class files in the directories and JAR files that are in your classpath.

Add the current directory to your classpath:

set CLASSPATH=C:\Sun\AppServer\jdk\lib;C:\Sun\AppServer\jdk\jre\lib;.

Notice the ";." at the end.

(Note: If the CLASSPATH environment variable is not set at all, Java will look in the current directory by default).

You can also use the "-cp" (or "-classpath") option as Fred suggests, to set the classpath on the command line explicitly.
[ October 09, 2006: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Derek B Smith

Joined: Oct 08, 2006
Posts: 9
that was it...thanks guys!

I agree. Here's the link:
subject: same error when using XP and Eclipse to run program
It's not a secret anymore!