Reputation: 4062
I'm trying to use a Tika class.
I am Following the instructions here: https://tika.apache.org/1.6/gettingstarted.html
I'm on OS X, and I'm using Eclipse 4.5.1 Mars 1.
The jar files have been built, and I don't understand how to make those classes available in my class. I don't know what they mean by 'as a Maven dependency' vs 'in an Ant project'
I've added tika-core-1.11.jar tika-parsers-1.11.jar in Project Properties / Build Path / Libraries
The code is:
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MediaType;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.AbstractParser;
import org.apache.tika.sax.XHTMLContentHandler;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
...
{... AutoDetectParser parser = new AutoDetectParser(); ... }
but
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
AutoDetectParser cannot be resolved to a type
How to make those classes known to the compiler ?
Upvotes: 1
Views: 4263
Reputation: 120
You should add both tika-core-{version}.jar and tika-parsers-{version}.jar to your build path. You should be able to do this by right clicking your project name and choosing Build Path->Add External Archives. (Note: these directions work in Eclipse Kepler with Tika 1.11, but other versions should be similar.)
Also make sure that you import org.apache.tika.parser.AutoDetectParser before referencing it in your code.
If you want full functionality, make sure you have added all the jars listed under Build Artifacts on the Tika Getting Started page (https://tika.apache.org/1.6/gettingstarted.html).
Upvotes: 1