Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

“NoClassDefFoundError” error

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,
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

> 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
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Hehehe, I love that page :-)