title: Tess4J working correctly from sources but not from JAR
body: <p>I'm using <code>maven</code> as build system and <code>IntelliJ</code> as development environment in <code>Java</code> and I want to do <code>OCR</code>.</p>
  
  <p>I added <code>tess4j</code> as maven dependency:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;net.sourceforge.tess4j&lt;/groupId&gt;
      &lt;artifactId&gt;tess4j&lt;/artifactId&gt;
      &lt;version&gt;LATEST&lt;/version&gt; &lt;!-- 4.2.1 --&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I wrote the following code to use <code>Tesseract</code>:</p>
  
  <pre><code>public class OpticalCharacterRecognition
  {
      private static final String TESS_DATA = "tessdata";
      public static final String DATA_FOLDER = getProgramDirectory() + separator + TESS_DATA;
      public static final String LANGUAGE = "eng";
  
      private ITesseract instance;
  
      public OpticalCharacterRecognition()
      {
          instance = new Tesseract();
          instance.setLanguage(LANGUAGE);
          instance.setDatapath(DATA_FOLDER);
      }
  
      // ...
  }
  </code></pre>
  
  <p>When running from <code>IntelliJ</code>, everything works fine. When running from <code>JAR</code>, the <code>OCR</code> doesn't recognize text correctly on my machine (e.g. the recognized text is an empty string but in <code>IntelliJ</code> it would be correctly recognized despite the image being the same) but it's hard to reproduce with a minimal test case for some reason. I'm just using <code>instance.doOCR(bufferedImage)</code>, nothing too special.</p>
  
  <p><a href="https://stackoverflow.com/a/27030735/3764804">I also tried invoking <code>ImageIO.scanForPlugins()</code></a> before <code>doOCR()</code> but it didn't help.</p>
  
  <p><s>Some users of the <code>JAR</code> however get this error:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI
  </code></pre>
  
  <p>This suggests that some files were missing from the <code>JAR</code> but they are not since <code>Tesseract</code> extracts and loads the <code>DLL</code>s from the <code>JAR</code> for use.</p>
  
  <p>Does <a href="https://digi.bib.uni-mannheim.de/tesseract/" rel="nofollow noreferrer">installing a <code>Tesseract</code> distribution</a> matter?</p>
  
  <p></s>
  (Fixed by installing <a href="https://www.microsoft.com/en-us/download/details.aspx?id=53587" rel="nofollow noreferrer">Microsoft Visual C++ 2015 Runtime</a>)</p>
  
  <p>My <code>pom.xml</code> build plugins:</p>
  
  <pre><code>&lt;!-- Generate Target JAR --&gt;
  &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
      &lt;version&gt;3.1.0&lt;/version&gt;
      &lt;configuration&gt;
          &lt;archive&gt;
              &lt;!-- Drop the META-INF/maven folder --&gt;
              &lt;addMavenDescriptor&gt;false&lt;/addMavenDescriptor&gt;
              &lt;manifest&gt;
                  &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                  &lt;classpathPrefix&gt;${libraries.directory}&lt;/classpathPrefix&gt;
                  &lt;mainClass&gt;LauncherClient&lt;/mainClass&gt;
              &lt;/manifest&gt;
              &lt;manifestEntries&gt;
                  &lt;Built-By&gt;Me&lt;/Built-By&gt;
              &lt;/manifestEntries&gt;
          &lt;/archive&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  
  &lt;!-- Copy JAR libraries to target folder --&gt;
  &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
      &lt;version&gt;3.1.1&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;copy-dependencies&lt;/id&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;copy-dependencies&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;outputDirectory&gt;${project.build.directory}/${libraries.directory}&lt;/outputDirectory&gt;
                  &lt;overWriteReleases&gt;false&lt;/overWriteReleases&gt;
                  &lt;overWriteSnapshots&gt;false&lt;/overWriteSnapshots&gt;
                  &lt;overWriteIfNewer&gt;true&lt;/overWriteIfNewer&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>I'm a bit desperate due to these weird issues so I'm not sure anymore what else to try to make it work flawlessly. All users (including myself) are only on <code>Windows</code>. I'm on <code>Windows 10 Pro</code>.</p>