0

I have configured tess4j test application as http://tess4j.sourceforge.net/tutorial/.
But when I run the project, it gives this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't obtain updateLastError method for class com.sun.jna.Native
at com.sun.jna.Native.initIDs(Native Method)
at com.sun.jna.Native.<clinit>(Native.java:148)
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown Source)
at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source)
at net.sourceforge.tess4j.Tesseract.init(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at tstest.Main.main(Main.java:22)
Java Result: 1

I am unable to find any comments related to tesseract, If anyone have done in this project please help.

This is the example code I am using:

import java.io.*;
import net.sourceforge.tess4j.*;

public class Main {

public static void main(String[] args) {
    File imageFile = new File(System.getProperty("user.dir") + "\\images\\1.png");
    Tesseract instance = Tesseract.getInstance(); //

    try {

        String result = instance.doOCR(imageFile);
        System.out.println(result);

    } catch (TesseractException e) {
        System.err.println(e.getMessage());
    }
 }
}

1 Answers1

0

Which JNA version are you using? Have you build it first? As explained on your linked page.

Based on the log in repository https://github.com/twall/jna.git the method updateLastError(int e) was removed in March 2013 (SHA1: d8e8889d).

To find out the JNA version execute

java -jar jna.jar 

Java Native Access (JNA) API Version 4
Version: 4.2.1 (b0)
Native: 4.0.1 (1a6047467b59e8748f975e03016ce3d9)
Prefix: linux-x86-64

edit A complete simple example was posted here: issue-with-the-libtesseract303-dll-in-netbeans

Community
  • 1
  • 1
SubOptimal
  • 22,518
  • 3
  • 53
  • 69
  • How can I see version of jna.jar –  Mar 15 '16 at 07:30
  • 1
    @user5954693 Have a look in my updated answer. You should also check the example code you are using (could you post it?). Seems your example code rely on a method which was removed in 2013. The current version of Tess4J ([Tess4J-3.0-src.zip](https://sourceforge.net/projects/tess4j/files/latest/download)) does not contain this function call. – SubOptimal Mar 15 '16 at 07:55
  • I tried to run as you said..`java -jar jna.jar`. It gives following error `Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't obtain updateLastError method for class com.sun.jna.Native at com.sun.jna.Native.initIDs(Native Method) at com.sun.jna.Native.(Native.java:148) ` –  Mar 15 '16 at 08:05
  • yes you are right. I am using [Tess4J-3.0-src.zip](https://sourceforge.net/projects/tess4j/files/latest/download) .. In this case how can I configure mytest project. –  Mar 15 '16 at 08:09
  • @user5954693 Have a look to the link I added. It point to a complete working example. – SubOptimal Mar 15 '16 at 08:36
  • I have used almost similar test application.as you can see the code I provided in my question. –  Mar 15 '16 at 08:45
  • @user5954693 Why not updating your JNA? I mean, it really states that this is the source of your problem. You can get a recent version from https://github.com/java-native-access/jna/releases. If it still does not work for you. Post more information about your setup. Where your `jna.jar` is comming from etc. – SubOptimal Mar 15 '16 at 09:02
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/106340/discussion-between-user5954693-and-suboptimal). –  Mar 15 '16 at 10:07