lkalay
lkalay

Reputation: 89

in order to parse html to string I used tika parser but i faced some problems such as libraries and errors in jdeveloper

Firstly, I have to download tika-bundle-0.9.jar but I cannot find it. Seconly,I wrote these

 try {
        URL itemURL = new URL("");
        DataInputStream daHTMLfromDaItem = new DataInputStream(itemURL.openStream());
        Tika tika = new Tika();
        Metadata metadata = new Metadata();
        Reader reader = tika.parse(daHTMLfromDaItem, metadata);

          String s=reader.toString();
          //System.out.print(s);


    } catch (Exception e) {
        e.printStackTrace();
    }

errors

Error(5,24): cannot access class org.apache.tika.Tika; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0

Error(6,33): cannot access class org.apache.tika.metadata.Metadata; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0

Error(15,13): class Tika not found in class mypackage.TikaParsing

Error(15,29): class Tika not found in class mypackage.TikaParsing

Error(16,13): class Metadata not found in class mypackage.TikaParsing

Error(16,37): class Metadata not found in class mypackage.TikaParsing

Also, I have to say that I added all necessary libraries except tika-bundle-0.9.jar . Do some problems occur because of tika-bundle-0.9.jar and how can i find tika-bundle-0.9.jar? I cannot find solution.

Thanks

Upvotes: 0

Views: 1144

Answers (2)

Gagravarr
Gagravarr

Reputation: 48346

The Tika Bundle is available from Maven. If you're using maven, then add something like:

<dependencies>
 <dependency>
   <groupId>org.apache.tika</groupId>
   <artifactId>tika-bundle</artifactId>
   <version>0.9</version>
   <scope>provided</scope>
 </dependency>
<dependencies>

If you're not using maven, then grab it by hand from a nearby maven repo, eg http://repo1.maven.org/maven2/org/apache/tika/tika-bundle/ (each version is in its own subdirectory)

Upvotes: 0

Andreas Dolk
Andreas Dolk

Reputation: 114807

The tika libraries have been compiled with Java 1.5 but you try to run them within a Java 1.4 environment. That's what the first error message is telling us. Version 49.0 is generated by Java 1.5, Version 48.0 by Java 1.4.x

Either run your application with Java 1.5+ or try to find an old version of tika that is compatible with Java 1.4.2

Upvotes: 1

Related Questions