title: JavaFX: Exception => java.lang.NoClassDefFoundError
body: <p>I'm new in building and deploying java applications.<br>
  I developed an application which should create an pdf-document. For this purpose I use the <b>pdfbox-library</b> from <a href="https://pdfbox.apache.org/" rel="nofollow noreferrer">apache</a>.   For building the application I use <b>ant.</b></p>
  
  <p>If I run the application on my IDE(Luna 4.4) no errors . But after building it and running the <b>.jar</b> on my pc or another pc, I get the following exception:  </p>
  
  <blockquote>
    <p><b> Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/apache/pdfbox/encoding/                           EncodingManager
            at helper.MyHelper.getSpecialCharacter(Unknown Source)
            at helper.MyHelper.formatString(Unknown Source)
            at controller.InvoiceC.fillView(Unknown Source)
            at controller.InvoiceC$MyTabListener.changed(Unknown Source)
            at controller.InvoiceC$MyTabListener.changed(Unknown Source)
            at </b>com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361)
            at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
            at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyO                           bjectWrapper.java:176)
            at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:142                           )
            at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
            at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
            at javafx.scene.control.SelectionModel.setSelectedItem(SelectionModel.java:102)
            at javafx.scene.control.TabPane$TabPaneSelectionModel.select(TabPane.java:717)
            at javafx.scene.control.TabPane$TabPaneSelectionModel.select(TabPane.java:735)
            at javafx.scene.control.TabPane$TabPaneSelectionModel.select(TabPane.java:656)
            at com.sun.javafx.scene.control.behavior.TabPaneBehavior.selectTab(TabPaneBehavior.java:122)
            at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderSkin$5.handle(TabPaneSkin.java:1332)
            at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderSkin$5.handle(TabPaneSkin.java:1317)
            at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
            at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
            at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
            at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.jav                           a:59)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
            at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
            at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
            at javafx.event.Event.fireEvent(Event.java:198)
            at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
            at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
            at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
            at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler                           .java:352)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler                           .java:275)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$355(GlassViewEventHandle                           r.java:388)
            at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387)
            at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
            at com.sun.glass.ui.View.notifyMouse(View.java:937)
            at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
            at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
            at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.ClassNotFoundException: org.apache.pdfbox.encoding.EncodingManager
            at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
            ... 50 more</p>
  </blockquote>
  
  <hr>
  
  <p>Following the <a href="https://pdfbox.apache.org/1.8/dependencies.html" rel="nofollow noreferrer">guide</a> I added all required libraries into my project.</p>
  
  <p><a href="https://i.stack.imgur.com/jsm4J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jsm4J.png" alt="libs"></a></p>
  
  <hr>
  
  <p>Here you can see the code, which is responsible for the exception:</p>
  
  <pre><code>public static String formatString(float value) {
  DecimalFormat df = new DecimalFormat("###,##0.00");
  String s = String.valueOf(df.format(value));
  
  try {
         s+= " " +getSpecialCharacter();
              switch(s.length()) {
                  case 5: s = "         " +s; 
                      break;
                  case 6: s = "       " +s;
                      break;
                  case 7: s = "     " +s; 
                      break;
                  case 8: s = "   " +s; 
                      break;
  
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
      return s;
  }
  
  public static String getSpecialCharacter() throws IOException {
      Encoding e = EncodingManager.INSTANCE.getEncoding(COSName.WIN_ANSI_ENCODING);
      return String.valueOf(Character.toChars(e.getCode("Euro")));
  }
  </code></pre>
  
  <hr>
  
  <p>I'm really confused, I hope someone will help me!!</p>