5

I have written a plain C++ application in VC6 that is using jni to call up a method in java. For doing so, I have included jni.h and other lib folders in the project directories.

the code compiles but when i run teh application it fails saying "jvm.dll is not found. reinstalling the application would fix it". But the jvm.dll is present in my pc.

If i set the working directory of the application to the location where the jvm.dll is, then it works like a charm. I cannot set the working directory of the application to the directory of jvm.dll as this application is going to be a dll in future.

I tried also updating the PATH variable in the system variables to the location of jvm.dll, but nothing works..

I suspect that the jvm.lib is loading the jvm.dll from certain directory location which is not provided by my application .. hence its failing,..

Please suggest me what is going wrong.

Thanks in advance.

Regards Raghavendra

user1821083
  • 71
  • 1
  • 5

2 Answers2

1

it fails saying "jvm.dll is not found. reinstalling the application would fix it".

Obviously that's your own error message, or Windows': not Java's, and it's incorrect. Reinstalling the application can't possibly have any effect on whether jvm.dll can be found.

You need to ensure that jvm.dll is on your PATH.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • 1
    @user1821083 Then you haven't done so correctly. PATH needs to contain a directory that contains a `jvm.dll`. – user207421 Nov 14 '12 at 09:14
  • @user1821083 Please make sure that you have added the path of jvm.dll and not jvm.lib. I made the same mistake just now. I can confirm that this answer allows the program to run without error. If you would like more assistance, I'd be happy to help, but let's begin with you posting the result of the following command in a cmd shell: "echo %PATH%". EJP- Just FYI, that error message is Windows, not user-generated. – StockB Jan 07 '13 at 20:19
  • 1
    @StockB It's still incorrect in this case. What would need to be reinstalled is Java, not the application, although from Windows' point of view it's all the same thing. However as Java is indeed installed the problem lies elsewhere. Not a great error message wherever it comes from. – user207421 Jan 07 '13 at 21:53
  • In my case, Java didn't need to be reinstalled, and reinstalling Java did not appear to properly add the jvm.dll directory to the PATH environment variable. I had to manually add it. – StockB Jan 07 '13 at 21:59
0

I got the same error even though my PATH is configured as StockB describes. Copying and pasting the DLL into my working directory fixed the issue. In my case, this was ../x64/Debug.

voluntier
  • 330
  • 4
  • 11