Question

I have a project that runs its output as a post-build event. Also this application uses JNI functions and thus needs to load jvm.dll (it is loaded automatically using jvm.lib).

  • I can build and run my program normally in visual studio.
  • I can also run the executable by double clicking it.
  • I can run it using the command line.

However if I enter the same command line as a post-build event I get the following error:

This application has failed to start because jvm.dll was not found. Re-installing the application may fix this problem.

I have added the path to jvm.dll to my PATH environment variable already. I'm not sure why it cannot find it.

Était-ce utile?

La solution

Thanks to technomage for helping me find the solution.

Apparently VS manipulates environment variables in its context. So I just had to set it again in the post-build event using the following:

set PATH=%PATH%;path_to_jvm.dll
"$(TargetPath)"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top