Solved

“NoClassDefFoundError” error

Posted on 2003-12-03
7
253 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 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…
This video teaches viewers about errors in exception handling.

747 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

11 Experts available now in Live!

Get 1:1 Help Now