Search code examples
c++visual-studio-2010java-native-interfacesolutionplatform

JNI: C++ platform in VS2010


I am writing a C++ dll application via JNI interface to call Java program from C++. I am using Java8, C++, Visual Studio 2010 professional and Windows 7. I am currently setting Configuration as ACtive(Debug), platform as Active(x64).

I noticed that if I select Active(x64) as platform, then there's no complains from VS. If I change it to Win32, it will complains about "Cannot open jni.h". If I change the configuration to release, platform as either x64 or Wind32, it will complain about "Cannot open jni.h" as well. Why is this? Can anyone explain?

I can build solution and produce dll using configuration=debug and platform=x64. I can then call this dll from my other c++ projects no problem. Do I have to change the configuration to release to release the dll to the system? What is the purpose of release and debug?

If anyone have documentation about solution configuration, please share as well.

Thank you.


Solution

  • For the include issue, make sure that your project configuration is pointing to the directory where jni.h exists. That is basically all you need to do.

    As to debug and release, the release version is the one you must build if you plan to distribute your JNI DLL to third parties (for example, your customers). The difference is that the release version will use the "release" Microsoft runtime libraries, which can be distributed to any PC, free of charge.

    It is not legal (as per the Microsoft license agreement) to distribute debug versions of your DLL since the debug version uses the Microsoft Debug runtime libraries. These debug libraries are only available to persons who have a valid Visual Studio 2010 installation.