Solved

“NoClassDefFoundError” error

Posted on 2003-12-03
7
256 Views
Last Modified: 2010-03-31
I am working on project that retrieve a web page and the images it contains to local storage, so that I can look at the web page loaded from our local file system; command-line application that takes two arguments: The first argument represents the download directory into which the web page will be downloaded and the second argument represents the absolute URL of the web page to download.

After compilation, all class files are located under c:\classes\dkim18\crawler\ and all source code are located under c:\src\dkim18\crawler\. When I run my program by typing “java WebCrawler c:\classes\dkim18\crawler\  http://webdev.apl.jhu.edu/%7Emed/index.html” under c:\classes\dkim18\crawler\ dir, I have “NoClassDefFounder” error. If I compile and run same way under c:\src\dkim18\crawler\ dir, my program works.

My question is that why do I have “NoClassDefFoundError” error when I run my program under c:\classes\dkim18\crawler\ and why my program runs under c:\src\dkim18\crawler\ dir?

Thanks,
0
Comment
Question by:dkim18
  • 3
  • 3
7 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 9865093
> When I run my program by typing “java WebCrawler c:\classes\dkim18\crawler\  http://webdev.apl.jhu.edu/%7Emed/index.html”

Why do you put the c:\classes...  bit in the command line?

What is the actual exception?

Sounds like you're not copying a class across to the classes dir...

java -cp . WebCrawler c:\classes\dkim18\crawler\  http://webdev.apl.jhu.edu/%7Emed/index.html
0
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
ID: 9865114
think it should be:

java -classpath c:\classes dkim18.crawler.WebCrawler c:\classes\dkim18\crawler\  http://webdev.apl.jhu.edu/%7Emed/index.html
0
 
LVL 9

Assisted Solution

by:yongsing
yongsing earned 25 total points
ID: 9865120
You need to add c:\classes\dkim18\crawler\ to your CLASSPATH. You can add it in the command window:

SET CLASSPATH=%CLASSPATH%;c:\classes\dkim18\crawler
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 92

Expert Comment

by:objects
ID: 9865123
compiling is working so perhaps you already have c:\classes in your classpath so you can just do:

java dkim18.crawler.WebCrawler c:\classes\dkim18\crawler\  http://webdev.apl.jhu.edu/%7Emed/index.html

0
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 25 total points
ID: 9865127
oh yeah... bah...

hehehe

cd \classes
java -cp . dkim18.crawler.WebCrawler c:\classes\dkim18\crawler\  http://webdev.apl.jhu.edu/%7Emed/index.html

like objects and yongsing said...
0
 
LVL 92

Expert Comment

by:objects
ID: 9865251
if its not already there your life will be  alot easier if you ad c:\classes to classpath in System Properties.

Some bedtime reading on the classpath:
http://mindprod.com/jgloss/classpath.html
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9865259
Hehehe, I love that page :-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question