Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

NoClassDefFoundError msg

I have WebCrawler.java and CrawlerExcpetion.java under c:\src\dkim18\crawler\ and I have WebCrawler.class and CrawlerExcpetion.class under c:\classes\dkim18\crawler\. When I run this program under c:\classes\dkim18\crawler\ dir, I have the following error msg:

Exception in thread “main” java.lang.NoClassDefFoundError: c:\classes\dkim18\crawler\

Why am I having this error?

0
dkim18
Asked:
dkim18
1 Solution
 
CEHJCommented:
Have you compiled all the classes?
0
 
CEHJCommented:
Please post the full error message too:

>>Exception in thread “main” java.lang.NoClassDefFoundError:

misses out the most important piece of info (the class name)
0
 
objectsCommented:
Ensure c:\classes is in your classpath, and you are specifying the full classname:

java dkim18.crawler.WebCrawler
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
objectsCommented:
or you can specify the classpath on the command line:

java c:\classes;%classpath% dkim18.crawler.WebCrawler
0
 
dkim18Author Commented:
Have you compiled all the classes?
>>yes

Please post the full error message too:
>>Exception in thread “main” java.lang.NoClassDefFoundError: c:\classes\dkim18\crawler\

when I run this :
javac -d classes -sourcepath src -classpath classes src\dkim18\crawler\WebCrawler.java

I got class files under c:\classes\dkim18\crawler\ and run program in this dir.
0
 
objectsCommented:
> javac -d classes -sourcepath src -classpath classes src\dkim18\crawler\WebCrawler.java

A lot easier to compile from the same directory as the source files :)
0
 
maheshexpCommented:
move to directory ..\src and type this command

java -cp "." src.dkim18.crawler.WebCrawler.java
0
 
objectsCommented:
As i mentioned above:

java c:\classes;%classpath% dkim18.crawler.WebCrawler

will work from any directory.
0
 
CEHJCommented:
Running with this command line:

>>java c:\classes;%classpath% dkim18.crawler.WebCrawler

Will mean that your source file for WebCrawler should start with

package dkim18.crawler;
0
 
objectsCommented:
pretty sure it already does, but if theres a problem it can be dealt with when this problem is solved.
0
 
objectsCommented:
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now