Solved

“NoClassDefFoundError” error

Posted on 2003-12-03
7
254 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

910 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now