开发者

Nutch problem: java.lang.NoClassDefFoundError

I'm trying to run Nutch on my Windows machine. I have Nutch, Java, Tomcat, and Cygwin installed. When I try to run the crawl command in Cygwin, I get the following error:

java.lang.NoClassDefFoundError: org/apache/nutch/crawl/Crawl
Caused by: java.la开发者_开发技巧ng.ClassNotFoundException: org.apache.nutch.crawl.Crawl
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.nutch.crawl.Crawl.  Program will exit.
Exception in thread "main"

My Java is a bit rusty, but this seems to be telling me that the Crawl class doesn't exist. If this is the case, how do I go about finding it -- and making sure my system is aware of its existence?


You must add the nutch jar to your classpath. See here how

It appears that the nutch distribution does not ship with a jar. You have to build it yourself using the ant build.xml. Type ant jar in the nutch directory (if you have ant installed), and it will make the jar.


for nutch-1.4, running

ant job

from within the nutch directory, and then moving the resulting nutch-*.job file from the build subdirectory into the src subdirectory, did the trick for me.


The JVM is telling you that it cannot find the Crawl class. This is most likely because the command line arguments being passed to the java command are not specifying the correct classpath. (The classpath is a search path used when searching for classes, and is typically set on the command line or using the CLASSPATH environment variable.)


What version are you using though ? Because some version include the .jar, however the recent ones like 1.2 does not and there is a warning somewhere telling you that you must build it yourself.


I don't know how Old it is, I had the same problems with nutch 1.4, well my solution:

  • set NUTCH_JAVA_HOME to the java home folder
  • set NUTCH_HOME
  • set JAVA_HOME
  • set CLASSPATH to include all required jar files

open nutch in bin and

  1. change cygwin manually to true
  2. DELETE the native folder from the lib folder

99% Crawl should output something familiar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜