java.lang.UnsatisfiedLinkError: no jSerialComm in java.library.path

153 Views Asked by At

If I checked this, my program (simple java coding) gives this exception but else it is running and displaying desired output

Details To communicate with the device I have to make a connection with it through comport using SerialPort. I used RxTx library before but it had bug in it so I switched to JSerialComm. I followed the instructions on the site and install the app according to it. my program is running but there is this exception below which is now disturbing my desired output.

"java.lang.UnsatisfiedLinkError: no jSerialComm in java.library.path: C:\Program Files\Eclipse Adoptium\jdk-21.0.1.12-hotspot\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.0.0_x64__8wekyb3d8bbwe;C:\Program Files\Eclipse Adoptium\jdk-21.0.1.12-hotspot\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Eclipse Adoptium\jdk-17.0.8.101-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Maven\apache-maven-3.9.5\bin;C:\Users\Toobaa.khan\AppData\Local\Microsoft\WindowsApps;;C:\Users\Toobaa.khan\AppData\Local\Programs\Microsoft VS Code\bin;."

Library using jSerialComm-2.10.4.jar

I tried pasting the .jar file in these two path 1- C:\Program Files\Eclipse Adoptium\jdk-21.0.1.12-hotspot\bin; 2- C:\Users\Toobaa.khan\AppData\Local\Microsoft\WindowsApps;;C:\Users\Toobaa.khan\AppData\Local\Programs\Microsoft VS Code\bin;

still the same error

Also this is what I am getting when running my JavaFx APplication project that contains the same Jserial.jar file

Additional Info Platform: Visual Studio Code.

pom.xml File:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>app.creatingpdfs</groupId>
    <artifactId>projectcreatepdfs</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>13</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>13</version>
        </dependency>
        <dependency>
            <groupId>com.fazecast</groupId>
            <artifactId>jSerialComm</artifactId>
            <version>[2.10.3,2.10.4]</version>
        </dependency>
        <dependency>
            <groupId>com.aspose.pdf</groupId>
            <artifactId>aspose-pdf</artifactId>
            <version>23.1</version>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>1.8</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running -->
                        <!-- Usage: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>app.creatingpdfs.App</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
1

There are 1 best solutions below

0
g00se On

Try replacing the plugin config with the following:

        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.6</version>
            <executions>
                <execution>
                    <!-- Default configuration for running -->
                    <!-- Usage: mvn clean javafx:run -->
                    <id>default-cli</id>
                    <configuration>
                        <mainClass>app.creatingpdfs.App</mainClass>
                    </configuration>
                    <options>
                        <option>-Djava.library.path=C:\Users\Toobaa.khan</option>
                        <option>-DjSerialComm.library.path=C:\Users\Toobaa.khan</option>
                    </options>
                </execution>
            </executions>
        </plugin>

Obviously the correct dll will have to be at the path shown