Solved

“NoClassDefFoundError” error

Posted on 2003-12-03
7
255 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

776 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