15

I'm getting the following error when running an executable I created on a 64-bit machine using C++ code:

"Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries"

My PATH (shown below) obviously points to jvm.dll since I have that file in both C:\Progra~1\Java\jdk1.6.0_17\jre\bin and C:\Windows\System32

PATH=C:\Program Files (x86)\Gmake\bin;C:\Program Files (x86)\apache-ant-1.7.1\bin;C:\Progra~1\Java\jdk1.6.0_17\bin;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools;C:\Progra~1\Java\jdk1.6.0_17\jre\bin\server;C:\Progra~1\Java\jdk1.6.0_17\jre\bin;C:\Windows\System32

Does anybody have any ideas as to what would cause this error? Thanks.

JoshDM
  • 4,939
  • 7
  • 43
  • 72
Brittany
  • 161
  • 1
  • 2
  • 4

6 Answers6

6

Use dependency walker to figure out what dll is missing.

Omry Yadan
  • 31,280
  • 18
  • 64
  • 87
  • Thanks for the reply. This is a great tool. When running the profiler, I'm getting an error: LoadLibraryA("C:\bin\verify.dll") returned NULL by thread 1. Error: The specified module could not be found (126) It says that it is being called by c:\windows\system32\JVM.DLL Two questions that maybe you can help resolve: 1) Why is it calling the system32 JVM instead of the one in my PATH? 2) Why would it try to look in C:\bin for any dll's? Thanks again. – Brittany Mar 25 '10 at 17:50
  • 3
    Java got a nasty tendency to install binaries into Windows\System32. you are probably running those instead of the one later in your path. if you intend to manually add java to the path just delete java and javaw from windows\system32. about the dll location, no idea. – Omry Yadan Mar 25 '10 at 18:01
5

I have the same issue when I run the java.exe in my Windows2008 R2 version.

my path was

PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files\System Center Operations Manager 2007\
;C:\Java\jdk1.6.0_33\bin

when I run the java.exe under C:\Java\jdk1.6.0_33\bin, it works fine. I found that within the c:\Windows\System32\ comes with a copy of java.exe. When I run the c:\Windows\System32\java.exe, it shows the same error:

C:\>Windows\System32\java.exe
Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries

I fixed this issue by moving the C:\Java\jdk1.6.0_33\bin to the beginning of the PATH environment:

PATH=C:\Java\jdk1.6.0_33\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\
Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\System Center
Operations Manager 2007\

Hope this help.

hzhsun
  • 114
  • 1
  • 5
2

In my case, there was a jvm.dll file in the same folder as my exe file. I simply deleted the jvm.dll from there and it worked. Probably, it preceded the one in the PATH

MGoksu
  • 510
  • 6
  • 13
2

This is how I solved a similar problem:

Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
1

I got this error as my PATH (environment variable) has not set correctly.

  1. while setting PATH variable, set path of jvm.dll as a very first path in the list
  2. Reboot your machine.

Note: Do not move jvm.dll to your project directory.

0

I had a complicated case. There was a jvm.dll file in the same folder as my exe file. I deleted it (because it shouldn't be there) but jvm.dll couldn't be find then.

I wanted to solve it by adding %JAVA_HOME%\jre\bin\server to my PATH because jvm.dll is located there. However, it didn't work. It turned out that the Windows loader won't expand the JAVA_HOME variable during searching for jvm.dll in the paths specified in PATH because I defined JAVA_HOME as user's variable. When I defined JAVA_HOME as a system variable, it started working as expected.

MazeGen
  • 180
  • 3
  • 14