Seems the library definition only allows Jars or Folders.
How can I assure that the DLL follows the jar file when the app is built?
Now you need to configure NetBeans IDE. From the main menu select Tools → Options and in the popup window that appears, click on the C/C++ icon to open the “Options” dialog box of C/C++, as shown in Figure 6. Notice: If Cygwin is not installed on your system, read and follow the instructions shown here.
Introduction to Java Native Interface: Establishing a bridge between Java and C/C++ JNI (Java Native Interface) is a foreign function interface that allows code running on JVM to call (or be called by) native applications. Using JNI, one can call methods written in C/C++ or even access assembly language.
Assuming you are referring to building a NetBeans Platform App (or module), then you can place the DLL in the "release/modules/lib/" folder. This is per the platform FAQ:
Additional information here:
If you are asking more generally, then I think most people package the DLL inside the jar, then extract it to a temp location upon application startup. e.g.
If that's not what you're looking for, then you'll need to provide more information as to what you're trying to do.
netbeans won't do it on its own, but since it uses ant behind the scenes there's a workaround.
you should create a subdirectory named jni
in your project directory (c:\path\to\mynetbeansproject\jni
), put all the .dll, .so and .jnilib files in there (the native stuff), and add the following lines to the build.xml
file you find in your project directory, just before the </project>
tag:
<target name="-post-compile">
<copy todir="${dist.dir}/lib">
<fileset dir="jni" />
</copy>
</target>
then add the jar file to your project just like you always do. :)
the snippet you inserted in build.xml
will make sure that the native libraries follow your jar files in the dist/lib
folder when you invoke "Clean and Build" from within netbeans (or ant
from the command line); the jvm will look for the .dll (.so, .jnilib) files in the same directory as the .jar that's loading them, so it will work.
note that this won't make your project run from within netbeans, because… I'm not really sure what goes on, but it looks like the library path (LD_LIBRARY_PATH
) doesn't include your projects' libraries, and there's no way I know of changing it from within netbeans. just put your native libraries in /Library/Java/Extensions
on mac os x, or just stash them in c:\windows\system32
under windows. if you're running a 64 bit windows with a 64 bit jvm, I have no clue; if you're running linux, you probably know where to stash them, but /usr/lib/java
might be a good bet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With