title: java.lang.NoClassDefFoundError: com/sun/jna/win32/StdCallLibrary after exporting to jar file
body: <p>I'm trying to write a java application to change my desktop wallpaper using cmd.</p>
  
  <p>The code I have written so far:</p>
  
  <pre><code>package me.kaes3kuch3n.main;
  
  import java.util.HashMap;
  
  import com.sun.jna.Native;
  import com.sun.jna.platform.win32.WinDef.UINT_PTR;
  import com.sun.jna.win32.*;
  
  public class WallpaperUpdater {
      public static void main(String[] args) {
  
          if(args.length != 1) {
              System.err.println("Usage: java -jar WallpaperUpdater.jar &lt;path_to_wallpaper&gt;");
          } else {
              String path = args[0];
  
              SPI.INSTANCE.SystemParametersInfo(
                      new UINT_PTR(SPI.SPI_SETDESKWALLPAPER), 
                      new UINT_PTR(0), 
                      path, 
                      new UINT_PTR(SPI.SPIF_UPDATEINIFILE | SPI.SPIF_SENDWININICHANGE));
          }
  
      }
  
      public interface SPI extends StdCallLibrary {
  
          //from MSDN article
          long SPI_SETDESKWALLPAPER = 20;
          long SPIF_UPDATEINIFILE = 0x01;
          long SPIF_SENDWININICHANGE = 0x02;
  
          SPI INSTANCE = (SPI) Native.loadLibrary("user32", SPI.class, new HashMap&lt;Object, Object&gt;() {
              /**
               * 
               */
              private static final long serialVersionUID = 1L;
  
              {
                  put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
                  put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
              }
          });
  
          boolean SystemParametersInfo(
                  UINT_PTR uiAction,
                  UINT_PTR uiParam,
                  String pvParam,
                  UINT_PTR fWinIni
                  );
      }
  }
  </code></pre>
  
  <p>It works just fine when I'm running it using Eclipse but after exporting it to a jar file it throws an error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/win32/StdCallLibrary
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.access$100(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at me.kaes3kuch3n.main.WallpaperUpdater.main(WallpaperUpdater.java:17)
  Caused by: java.lang.ClassNotFoundException: com.sun.jna.win32.StdCallLibrary
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      ... 13 more
  </code></pre>
  
  <p>I've added both the jna.jar and the jna-platform.jar to the build path, but it won't work. What am I missing?</p>