0

**hey everyone **

the story : update the jar file created using the shaded maven plugin works as intended the issue i faced lies in the opencv library i use it for webcam operations and when the jar is deployed it cannot locate the dll file is there a way to include the dll file in the jar ? .

this is the plugin :

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.4.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>Main_panel.Main</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

**this is the code where the issue occurs : **


 System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        VideoCapture  capture=new VideoCapture(0);

i hope i get some help soon , thank you so much for your patience .

  • 1
    I've never used Maven with javafx before but just got myself a javafx archetype and made a runnable jar with that and Shade. I can post it as an answer if you like. You probably would need only minimal changes to some ids in the pom – g00se Jun 25 '23 at 14:36
  • @g00se hello so i have an update it seems that the issue was with opencv library it cannot locate the dll when the jar is deployed , i'll make sure to update the post – Lemon juice Jun 25 '23 at 15:28
  • *is there a way to include the dll file in the jar ? .* In a word, no. The library has to be in the file system. You might be better off using `jlink` + `jpackage` to do all this – g00se Jun 25 '23 at 15:40
  • @g00se is there a tutorial that specifically does this? or something similar to it? – Lemon juice Jun 25 '23 at 15:51
  • [This](https://technojeeves.com/index.php/aliasjava1/111-making-native-installable-apps-with-java-9) touches on it, but you might find something JavaFX-specific if you're lucky – g00se Jun 25 '23 at 15:54
  • See also the [tag:javafx] section on [_Packaging_](https://stackoverflow.com/tags/javafx/info) – trashgod Jun 25 '23 at 16:52
  • JavaFX packages the JavaFX native libraries into jmods (which are built to handle both native and Java code), or (for the JavaFX maven artifacts) by including the native libraries in the artifact jars and then extracting them at runtime to [a local cache directory from which it then loads them](https://github.com/Glavo/jfx/blob/c1f6c995a0445d75f0a715e598437460026f4e45/modules/javafx.graphics/src/main/java/com/sun/glass/utils/NativeLibLoader.java#L116). That doesn't directly solve your problem with opencv, I just note how a similar problem was solved by a framework you use. – jewelsea Jun 25 '23 at 23:06
  • Related: [Running Executable Jar throws no opencv_java310 in java.library.path error but runs fine in IDE](https://stackoverflow.com/questions/42962216/running-executable-jar-throws-no-opencv-java310-in-java-library-path-error-but-r) and [https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing](https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing) – jewelsea Jun 25 '23 at 23:16
  • *Anywhere you use System.getProperty("user.dir") it refers your app root folder.* That is simply *wrong*. It refers to the [current directory](https://technojeeves.com/index.php/aliasjava1/91-find-the-current-directory-in-java) (where your app has been run from) which *could* be entirely different – g00se Jun 26 '23 at 09:40
  • @g00se you might want to comment on the answer to the [related question](https://stackoverflow.com/questions/42962216/running-executable-jar-throws-no-opencv-java310-in-java-library-path-error-but-r), to place the comment in context. – jewelsea Jun 26 '23 at 20:09
  • @jewelsea, thanks. Have done so – g00se Jun 26 '23 at 23:41

0 Answers0