Reputation: 197
I use tess4j library for my java app. I followed instructions and copied liblept168.dll and libtesseract302.dll into my project root folder. When I run my app with Eclipse, it works normally. But when I export it as runnable jar file, it gives me java.lang.NoClassDefFoundError - UnsatisfiedLinkError: The specified module could not be found. But I am sure, that program see this files, because earlier before I added this files it gave me other error, that files can't be found. I also used to copy this dlls to my jar archive, but it didn't help. I am absolutely sure, that I use right jre too. I just can't understand what can be wrong...
Tesseract1 api = new Tesseract1();
api.setTessVariable("tessedit_char_whitelist", "(),-+0123456789");
//part of code of getting image
String result = api.doOCR(image);
Any ideas?
UPD: I edited my manifest file as you said and it is:
Manifest-Version: 1.0
Rsrc-Class-Path: ./ jsoup-1.7.3.jar json_simple-1.1.jar Filters.jar ja i_core.jar jna-4.1.0.jar tess4j.jar jai_codec.jar jxl.jar myjsocksj.j ar jai_imageio.jar
Class-Path: jai_imageio.jar tess4j.jar
Rsrc-Main-Class: com.slando.MainWindow
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Then there were errors about missing dll files and I copied them into jar. And then the same error began to occure.
Stacktrace:
java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.Tesseract1
at com.slando.parser.ImageParser.getNumberFromImage(ImageParser.java:109)
at com.slando.parser.ImageParser.loadNumberFromImage(ImageParser.java:138)
at com.slando.parser.ImageParser.loadNumberFromImage(ImageParser.java:144)
at com.slando.parser.PageParser.loadPhone(PageParser.java:202)
at com.slando.parser.PageParser.loadFullInfo(PageParser.java:319)
at com.slando.HttpThread.run(HttpThread.java:58)
at java.lang.Thread.run(Unknown Source)
One more:
java.lang.UnsatisfiedLinkError: The specified module could 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.Native.register(Native.java:1396)
at com.sun.jna.Native.register(Native.java:1156)
at net.sourceforge.tess4j.TessAPI1.<clinit>(Unknown Source)
at com.slando.parser.ImageParser.getNumberFromImage(ImageParser.java:109)
at com.slando.parser.ImageParser.loadNumberFromImage(ImageParser.java:138)
at com.slando.parser.ImageParser.loadNumberFromImage(ImageParser.java:144)
at com.slando.parser.PageParser.loadPhone(PageParser.java:202)
at com.slando.parser.PageParser.loadFullInfo(PageParser.java:319)
at com.slando.HttpThread.run(HttpThread.java:58)
at java.lang.Thread.run(Unknown Source)
Upvotes: 0
Views: 6152
Reputation: 1163
Eclipse has the tess4j jar in its classpath, but your system does not. To distribute this project, the tess4j jar needs to be in the classpath in your jar manifest. You can also add the path to this jar to the classpath environment variable in your system settings.
Someone else had the same problem
Upvotes: 1