I want to use dll in my java program. I saw that we want to use __declspec(dllexport) to export my function in dll. Do we also want this while exporting using jniexport for java? I am using mingw compiler?
Asked
Active
Viewed 843 times
2
-
1Take a look into that post: https://stackoverflow.com/questions/25454697/how-to-call-a-method-in-dll-in-a-java-program – KimKulling Feb 08 '18 at 10:17
-
I already saw it but it cannot answer my question. – Sri vishnu Bharat Feb 08 '18 at 10:29
-
Whether jniexport itself enough or i want to use __declspec(dllexport) to export my function into library – Sri vishnu Bharat Feb 08 '18 at 13:55
1 Answers
0
No, you need to wrap your dll call and use the JNIEXPORT-macro from the native-interface in Java.
The __declspec(dllexport) extension is a Microsoft-specific extension used in the VS-compiler to automatically export / import functions and classes/methods to dll's.

KimKulling
- 2,654
- 1
- 15
- 26
-
Thankyou for your answer. Can i use the following function? JNIExport int JNICall java_Main_add (int a,int b){} is it enough. – Sri vishnu Bharat Feb 08 '18 at 14:16
-
Yes, normally this shall be enought. And you need to load the wrapper package into your application. – KimKulling Feb 08 '18 at 14:17
-
-
Yes, here is a tutorial how to do so: https://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html – KimKulling Feb 08 '18 at 14:20