JNI is the Java Native Interface, you will need to download and install the Java SDK. Note the installation directory (ie/ c:\j2sdk1.4.1_02 ) for use later. If you are using MSYS add a line similiar to the following in /etc/fstab and then restart MSYS:

c:/j2sdk1.4.1_02      /java

In MSYS the JNI DLL can be generated using the following (NOTE: -Wl has an 'L' not a '1'):

gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at   -I/java/include -I/java/include/win32   -shared -o JavaImp.dll someJavaImp.c

In a standard command console it can be generated as follows (one continuous line):

gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at
  -Ic:/j2sdk1.4.1_02/include -Ic:/j2sdk1.4.1_02/include/win32
  -shared someJavaImp.c -o JavaImp.dll

Where JavaImp.dll should be named whatever you refer to the library as in your .java file. To use the above dll you would refer to it as follows in your java classes code:

System.loadLibrary( "JavaImp" );

If you encounter problems ensure your CLASS_PATH and PATH are set appropriately for your environment. Please refer to Java Native Interface for further details on using a JNI DLL in java code.


Really thankful to you for sharing the information and also explaining the way of how to approach with it.Thats really good stuff thank once again.


I'm trying to compile a JNI dll using the options listed here, however, my C implementation code calls functions in a non-standard library. Where would be an appropriate place to pass the path to my library? After the -Wl, option? Thank you for your patience, I don't have much experience with gcc

This wiki is not a forum for discussion of usage issues. Please use the mingw-users@lists.osdn.me list instead. We do not allow creation of comments by anonymous or untrusted users, on any page.
Site Status

Site maintenance performed successfully, site online Dec 13th 12:00 AM Eastern.