Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load DLL's from inside JAR #23

Closed
jjYBdx4IL opened this issue Jun 14, 2019 · 4 comments
Closed

Load DLL's from inside JAR #23

jjYBdx4IL opened this issue Jun 14, 2019 · 4 comments
Assignees

Comments

@jjYBdx4IL
Copy link
Contributor

The code failed to load the dll from jar because the jar file on maven central does not contain the dll.

@melloware
Copy link
Owner

Yes we did not package the DLL. See our instructions in the readme.txt here: https://github.com/melloware/jintellitype/blob/master/readme.txt

@jjYBdx4IL
Copy link
Contributor Author

for a better adoption I recommend packaging with the jar.

@melloware
Copy link
Owner

Yep I reopened this ticket that is a good idea. Do you have an example library you can point me to that packages them inside the JAR?

@melloware melloware reopened this Jun 18, 2019
@melloware melloware self-assigned this Jun 18, 2019
@melloware melloware changed the title no dlls in maven jars Put DLL's inside JAR Jun 18, 2019
@melloware melloware changed the title Put DLL's inside JAR Load DLL's from inside JAR Jun 18, 2019
@jjYBdx4IL
Copy link
Contributor Author

jjYBdx4IL commented Jun 18, 2019

open resource-stream, copy it to a file named System.getProperty("user.home")+"/AppData/LocalLow/jintellitype/jintellitype."+version+".dll" if that does not exist alrady, then use System.load to load it. Should work that way if there are all dependent libraries available on the system. If loading fails, remove and replace the existing extracted dll because it may have been corrupted. Some people also simply extract the dll to the temp folder and register a VM shutdown hook to remove it, but that's inferior because it's slower because it doesn't get cached and always needs to be extracted.

Ofc if you really want to do the extraction correctly, you need a blocking lock on the containing folder or open the target file in exclusive mode, the latter could produce a non-critical concurrency failure during the initial extraction when there are two processes trying to achieve the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants