I'm working with a jni application that loads a dll library, but the load of it is taking too long. The dll is in the path. As a relevant informat, this dll depends on other oracle dlls that are also in the path.
System.loadLibrary("exmaple.dll");
Do you have any idea why the load nev开发者_如何学JAVAer ends?
To begin with, you might want to identify if it's JNI slowing down the load or if the DLL just loads slowly in Windows.
You can test loading a dll by using the command
rundll32 example.dll,testMethod
You'll get an error that test method doesn't exist, but it will load the DLL and it's dependencies. You can time that and see how long it takes.
If if loads slowly with Rundll32, then try turning off virus checkers. Also check how much free memory you have.
If it's JNI that's slowing things down, you could try switching to JNA as an alternative.
I made some tests and it seems to be related with threads. When I put a breakpoint in the loadLibrary call, it won't go to the next step. It only goes to the next step after I reactivate other threads in my application. I couldn't figure if this is a java bug or some thread issue. I'm using JDK1.6.0_11.
If someone faces the same problem in future, check for a thread issue.
精彩评论