Below given Java JNI program works fine with the environment (1). But if i change the environment to (2) it give error. Any help appreciated to solve this error.
Java Code :
package avajjni;
public class AvajJNI {
static{
//Environment (1)
//System.load("D:\\cpro\\c_jni_library\\dist\\Debug\\MinGW_32-Windows\\libc_jni_library.dll");
//Environment (2)
System.load("D:/cpro/c_jni_library/dist/Debug/Cygwin_64-Windows/libc_jni_library.dll");
}
public native void fnDisplayData();
public static void main(String[] args) {
AvajJNI obj = new AvajJNI();
obj.fnDisplayData();
}
}
C Code (.c)
#include <stdio.h>
#include "avajjni_AvajJNI.h"
JNIEXPORT void JNICALL Java_avajjni_AvajJNI_fnDisplayData
(JNIEnv *env, jobject obj){
printf("JNI Method Called\n");
}
Environment (1) where works fine:
OS : Windows 8.1 64 bit
Java jdk1.8.0_51 (32 bit)
Mingw 32 bit
C Compiler Option : -shared -m32 -Wl,--add-stdcall-alias
Netbeans runs using 32 bit Java
Environment (2) where it gives error:
OS : Windows 8.1 64 bit
Java jdk1.8.0_51 (64 bit)
Cygwin 64 bit
No Compiler Option
"C:\cygwin64\bin" added to path environment variable
Netbeans runs using 64 bit Java
Error :
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180126947, pid=7528, tid=20276
#
# JRE version: Java(TM) SE Runtime Environment (8.0_51-b16) (build 1.8.0_51-b16)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.51-b03 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [cygwin1.dll+0xe6947]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
Please let me know if any additional information needed
I reproduce the problem, then show how to solve it:
mdorey@VXD0141 ~/tmp $ cat avajjni/AvajJNI.java package avajjni; public class AvajJNI { static{ //Environment (1) //System.load("D:\\cpro\\c_jni_library\\dist\\Debug\\MinGW_32-Windows\\libc_jni_library.dll"); //Environment (2) System.load("C:\\cygwin64\\home\\mdorey\\tmp\\libc_jni_library.dll"); } public native void fnDisplayData(); public static void main(String[] args) { AvajJNI obj = new AvajJNI(); obj.fnDisplayData(); } } mdorey@VXD0141 ~/tmp $ cat AvajJNI.c #include "stdio.h" typedef unsigned long long __int64; #include "avajjni_AvajJNI.h" JNIEXPORT void JNICALL Java_avajjni_AvajJNI_fnDisplayData (JNIEnv *env, jobject obj){ printf("JNI Method Called\n"); } mdorey@VXD0141 ~/tmp $ javac avajjni/AvajJNI.java mdorey@VXD0141 ~/tmp $ javah avajjni.AvajJNI mdorey@VXD0141 ~/tmp $ gcc -I /cygdrive/c/Program\ Files/Java/jdk1.8.0_72/include -I /cygdrive/c/Pro gram\ Files/Java/jdk1.8.0_72/include/win32 -o libc_jni_library.dll -shared Avaj JNI.c mdorey@VXD0141 ~/tmp $ java avajjni/AvajJNI # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180185145, pid=8780, tid=7560 # # JRE version: Java(TM) SE Runtime Environment (8.0_72-b15) (build 1.8.0_72-b15) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.72-b15 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [cygwin1.dll+0x145145] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # An error report file with more information is saved as: # C:\cygwin64\home\mdorey\tmp\hs_err_pid8780.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # mdorey@VXD0141 ~/tmp $ /cygdrive/c/Program\ Files/software.jessies.org/terminator/Resources/salma-ha yek/.generated/amd64_Cygwin/bin/java-launcher.exe avajjni/AvajJNI JNI Method Called mdorey@VXD0141 ~/tmp $