Where to place the dll file?

I am invoking a C ++ method using a DLL file in my Java project. Right now, I have hardcoded the path.

The application will be deployed on many machines, as well as running on several machines. Where should I put my dll file to load it and call it on any machine?

+4
source share
3 answers

I have seen applications that put DLLs in a JAR file. At run time, they extract the DLL from the JAR into a temporary directory and then access it.

This is not the most efficient approach, but the simplest from a deployment perspective.

+2
source

You need to make sure your DLL is in the classpath.

One way to do this is to specify the path to the DLL in the PATH environment variable.

Another option is to add it to the VM arguments in the LD_LIBRARY_PATH variable, for example:

java -Djava.library.path=/path/to/my/dll -cp /my/classpath/goes/here MainClass 

If you are developing a complex application that needs to be stable, you need to make sure that the necessary DLL is somewhere somewhere where the OS will look for it, perhaps it will think about the script / program installer.

+1
source

C: \ WINDOWS \ system32 (assuming C is the drive on which the windows are installed, maybe you can get it from the registry)

I used to use windows for a long time, and not an expert, so I did a Google search and found the link http://vlaurie.com/computers2/Articles/dll.htm

See the latest topic in the link (starting with the heading Using Regsvr32.exe to Register DLLs )

0
source

All Articles