I have programmed a small tool that takes an image and uses tesseract to extract data from it. I have used Java in Netbeans on a 64bit Windows 7 machine. So far, the programm compiles perfectly fine and does what I want - including tesseract -. But when I try to clean & build the finished project in Netbeans and try to run the generated .jar in the .cmd
java -jar "..\Users\Marv\Scantool.jar"
I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: The module can not be found
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.Native.open(Native.java:1759)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
at com.sun.jna.Library$Handler.<init>(Library.java:147)
at com.sun.jna.Native.loadLibrary(Native.java:412)
at com.sun.jna.Native.loadLibrary(Native.java:391)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:45)
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:283)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:219)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:168)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:152)
at ScanCards.ScanCards.extraction(ScanCards.java:64)
at ScanCards.ScanCards.scan(ScanCards.java:37)
at ScanCards.ScanCardsGUI.scanButtonActionPerformed(ScanCardsGUI.java:16
0)
at ScanCards.ScanCardsGUI.access$100(ScanCardsGUI.java:22)
at ScanCards.ScanCardsGUI$2.actionPerformed(ScanCardsGUI.java:73)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:20
22)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6535)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6300)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
So far I can narrow the problem down to this line in my code:
String strResult = instance.doOCR( file);
I have checked the "file" given to the OCR. It is a perfectly in tact .tif-image (as it works inside the Netbeans fine anyways). Another thing I thought that could be the problem that the .jar can't find the for tesseract necessary .dlls. So have copied the necessary .dlls into the "dist"-folder. With no success either. I have inbound the tess4j-1.3.0.jar into my project's library.
It is quite strange that everything runs perfectly fine inside of NetBeans. I think I miss a link to a library but I can't think of any.
That is all I can think of to provide you with. Thanks in advance!