0

I've developed a JNI application in MS Visual Studio that calls Java methods from within a C++ file. All necessary files, such as jvm.lib and jvm.dll, have been included in the "Debbuging->Environment", "Linker->Input->Additional Dependencies" and Linker->General->Additional Library Directories configuration properties. The application runs fine inside Visual Studio, but when running the .exe file directly, it complains that the jvm.dll is missing. So I've copied the file from C:\Program Files\Java\jdk1.6.0_45\jre\bin\server to my VS project where the executable resides, but then I receive the error The application was unable to start correctly (0x000007b). How can I reference third party libraries in the .exe file? I preferably want to export environment paths and dependencies during the VS build process.

Regards,
Chris

Windows 7 64bit
Java JDK 1.6.45 64bit
MS Visual Studio 2012

user46726
  • 47
  • 8
  • Do you confirm that your EXE is **statically** linked to jvm.dll? – manuell Mar 10 '14 at 12:17
  • @manuell I'm not sure, how can I verify whether it is statically linked or not? I have set the _LIB_,_INCLUDE_ and _PATH_ variables to point to the required .lib and .dll files (as noted in http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/bldaps_cls/common/bldaps_env_vars1_comm.htm). Now the executable finds the jvm.dll without having it in the same directory, but still getting the 0x000007b error. – user46726 Mar 10 '14 at 12:34
  • If you don't use LoadLibrary, then you link statically. Check my answer here: http://stackoverflow.com/a/21439331/1374704 – manuell Mar 10 '14 at 12:37
  • Ok, so static linking means the executable loads the .dll from its original location? Setting the dll path in the PATH environment variable at least solved the missing dll problem. But what could cause the error, any ideas? – user46726 Mar 10 '14 at 12:47

1 Answers1

0

The application was unable to start correctly (0x000007b) error, in your context, is typically caused by building a 32 bits EXE and trying to run it against a 64 bits DLL.

Check that all your files are indeed all 64 bits.

manuell
  • 7,528
  • 5
  • 31
  • 58
  • Yes, I've also suspected a 32/64 bit architecture issue, but unfortunately the attempt to use a 32bit Java also failed. Anyway, thanks for your help. – user46726 Mar 10 '14 at 14:47
  • Silly me, you were absolutely right. I added the dll path of my 64bit Java version, but in the development environment i pointed to $(JAVA_HOME) which is the 32bit environment. Finally, it's working! Thanks again for your support. :) – user46726 Mar 10 '14 at 14:54