Hi, 2009/3/14 Daniel Gultsch <dan...@gultsch.de>
> Hi guys > > I've just built and installed tika as described in [1] and now I want > to use it. I've tried java -jar ./tika-0.2.jar > > But I get: > Exception in thread "main" java.lang.NoClassDefFoundError: > org/apache/log4j/Layout Caused by: java.lang.ClassNotFoundException: > org.apache.log4j.Layout at java.net.URLClassLoader$1.run > (URLClassLoader.java:200) at java.security.AccessController.doPrivileged > (Native Method) at java.net.URLClassLoader.findClass > (URLClassLoader.java:188) at java.lang.ClassLoader.loadClass > (ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass > (Launcher.java:301) at java.lang.ClassLoader.loadClass > (ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal > (ClassLoader.java:320) Could not find the main class: > org.apache.tika.cli.TikaCLI. Program will exit. Taking a look at this I know what is wrong.. As you are executing the JAR using the java command and the -jar switch, the classpath is completely ignored and the JARs manifest file used. Therefore the Java runtime is expecting the JARs to be in the location specified in the manifest file relative to the JAR location - as the manifest file just has the JAR names, the Java runtime is looking in the same folder as the tika-0.2.jar for the dependencies. To get the software executing you can do something similar to the following from your extracted tika folder: d...@amadeus:~/Sandbox/apache-tika-0.2$ mvn dependency:copy-dependencies d...@amadeus:~/Sandbox/apache-tika-0.2$ cd target/dependency/ d...@amadeus:~/Sandbox/apache-tika-0.2/target/dependency$ cp ../tika-0.2.jar . d...@amadeus:~/Sandbox/apache-tika-0.2/target/dependency$ java -jar tika-0.2.jar --help In summary, as long as the dependencies are in the same folder as the tika-0.2.jar it will work. > [1] http://lucene.apache.org/tika/gettingstarted.html > > Depending on when tika-0.3 releases, we may want to update the website accordingly. Cheers, Dave