• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

same error when using XP and Eclipse to run program

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

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
derek


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

From DOS:
C:\temp>javac DooBee.java

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) {
System.out.print("Doo");
System.out.print("Bee");
x += 1;
}

if (x == 3) {
System.out.print("Do");
} // 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:\Sun\AppServer\jdk\lib;C:\Sun\AppServer\jdk\jre\lib

C:\temp>echo %JRE_LIB%
C:\Sun\AppServer\jdk\jre\lib
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\temp>echo %CLASSPATH%
C:\Sun\AppServer\jdk\lib;C:\Sun\AppServer\jdk\jre\lib


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 ]
 
Derek B Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that was it...thanks guys!

derek
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic