Tess4j和NetBeans Java程序 - 问题" AWT-Eventqueue-0"不满意链路错误

时间:2016-08-09 13:31:47

标签: java windows netbeans tess4j

我编写了一个小工具来拍摄图像并使用tesseract从中提取数据。我在64位Windows 7机器上使用了Netbeans中的Java。到目前为止,该程序编译完全正常,并做我想要的 - 包括tesseract - 。但是,当我尝试清洁&在Netbeans中构建完成的项目,并尝试在.cmd

中运行生成的.jar
java -jar "..\Users\Marv\Scantool.jar"

我收到以下错误:

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)

到目前为止,我可以在我的代码中将问题缩小到这一行:

String strResult = instance.doOCR( file);

我检查了&#34;文件&#34;给予OCR。这是一个完美的机智.tif-image(因为它无论如何都在Netbeans内部工作)。我认为另一件事可能是.jar无法找到必要的问题.dlls。所以将必要的.dll复制到&#34; dist&#34; -folder中。也没有成功。 我已将tess4j-1.3.0.jar输入到我的项目库中。

很奇怪,NetBeans内部的一切都运行得很好。我想我错过了一个图书馆的链接,但我无法想到。

这就是我能想到的为你提供的一切。提前致谢!

1 个答案:

答案 0 :(得分:0)

好吧,我找到了某种解决方法......

File dummy = new File( ScanCards.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile().getParentFile();
String dirStr = dummy.getPath();
instance.setDatapath( dirStr);
String result = instance.doOCR( file);

实际上我仍然无法运行.jar文件,但我可以从控制台运行它。因此,我只使用批处理文件(包括&#39; java -jar PATH \ TO \ MY \ FILE&#39;代码)来启动程序,而不是runnable .jar。

我认为,关键在于&#34; java -jar&#34;,好像通过打开.jar直接java没有加载?