Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
`import java.io.File; 
import net.sourceforge.tess4j.Tesseract; 
import net.sourceforge.tess4j.TesseractException; 
class Test { 
    public static void main(String[] args) 
        Tesseract tesseract = new Tesseract(); 
        try { 
            String text = tesseract.doOCR(new File("captcha.jpg")); 
            System.out.print(text); 
        catch (TesseractException e) { 
            e.printStackTrace(); 

I am getting these error messages

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Pointer
        at Test.main(Detection.java:9)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Pointer
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 1 more

My folder looks like this:

Main folder:

  • Detection.java

  • lib -> Here I have the "tess4j-3.4.8.jar" file I got after downloading the tess4j and going into the dist folder

  • .captcha.jpg

  • I am not able to solve this issue. Please help.

    I am using visual studio code as my IDE.

    The solution above of YogendraR worked. You have to add the jar files in the lib folder of your tess4J folder in your project struture Project structure => Module => Dependencies. The jars files to add

    Add them here

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.