Search code examples
javaeclipsedlljava-native-interfacedependencies

Eclipse configuration to run a JNI project


I have a project that uses a few jar files which happen to be JNI wrappers calling some DLL libs. I included those jars in the classpath and specified the native library location for them from within Eclipse (java build path->Libraries), as suggested by some posts in this forum.

However I still received error like: C:\projects\java_workspace\lib\\xyz.dll: Can't find dependent libraries

Some interesting facts: 1. If I set %CLASSPATH% for jar files and %PATH% for DLL path as env variables and run the program from command console, it works like a charm; 2. I used Dependency Walker to check the xyz.dll in question, even though I can find the dependent dll files in the expanded tree under xyz.dll, from the list box at the bottom I did notice there were two dll files that Dependency Walker complains "Error opening file, the system cannot find the file specified".

Anyone can help config the Eclipse env so I can run the program from within the IDE? Or any comments?

Thanks! John


Solution

  • Did you try setting the PATH environment variable in the 'run configuration'? (Right-click on the java file containing your main, then 'run as', then select 'run configuration'.)