title: loadlibrary issues in Java
body: <p>so I have this project in java that uses a jni .dll i wrote (which i've aptly named jniusb) that gives access to usb-hid devices.  i've been using it for several months now without any notable issues until yesterday when i tried to launch my program from the jar instead of directly from netbeans.  after a little debugging i characterized my issue as follows:</p>
  
  <ol>
  <li><p>clicking on the jar icon starts my program without loading the dll.  displaying the error messages in my gui revealed "no jniusb in java.library.path" even though i copied my dll to the java binaries folder (which always seemed to work in the past).</p></li>
  <li><p>i tweaked the code to find the current directory and use "System.load" (with the dll copied to the same folder as my jar) instead of "System.loadLibrary".  this approach threw the error "C:\Users\bpaik\Documents\NetBeansProjects\JniUsb\dist\jniusb.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform".  this made me scratch my head since i am most definitely working on an AMD 64-bit platform and running out of netbeans works with the same dll...</p></li>
  <li><p>running the jar from the command prompt (with either java.exe or javaw.exe) loads the dll just fine.  i thought that maybe this meant that i was having admin privileges issues so i tested the theory by going to the java executable and granting admin privileges, but this did not change anything.  (and i'm also pretty sure i've used load/loadlibrary before without admin...) </p></li>
  </ol>
  
  <p>i am no java expert so i've pretty much exhausted my debugging abilities and am now hoping that someone with a little more experience than i will recognize the issue i've described, thanks.</p>
  
  <p>UPDATE: so i've fixed the problem but I still have no idea what is going on.  i did a x86 build of my .dll and threw it into the folder with my jar and everything loaded/worked just fine.  so i guess somehow (even though i set the default program for my jar to be the x64 JVM) the jar i built with the x64 library in Netbeans is running in a 32-bit JVM.  to sum things up:</p>
  
  <ol>
  <li>my jar is built with the x64 library in netbeans and runs fine with the x64 dll when launched from the command prompt.</li>
  <li>when launching the jar from the icon (with default program set to x64 java) my program and JVM somehow switch to a 32-bit JVM and work fine when i use the 32-bit version of my dll.</li>
  <li>trying to explicitly run my jar with the 32-bit java doesn't work at all.  my gui doesn't display and the command prompt briefly opens/closes... </li>
  </ol>