DLLs are loaded before the application is executed thus before any of your code is executed thus before addLibraryPath() is executed. This call is meant to do something different than you expect. Follow your platform guidelines for deploying dll files with your application.