SpaiR / imgui-java

JNI based binding for Dear ImGui
MIT License
587 stars 90 forks source link

Bug: Maven fat jar not working on windows #195

Open danilolr opened 1 year ago

danilolr commented 1 year ago

Version

1.86.10

What happened?

When running the fat jar on windows I got the message "no imgui-java on java.library.path"

Reproduction

I have a imgui-java with ImGui with this POM :

` <?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/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>org.example</groupId>
<artifactId>game-imgui</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>io.github.spair</groupId>
        <artifactId>imgui-java-app</artifactId>
        <version>1.86.10</version>
    </dependency>
    <dependency>
        <groupId>com.github.bhlangonijr</groupId>
        <artifactId>chesslib</artifactId>
        <version>1.3.3</version>
    </dependency>
    <dependency>
        <groupId>org.l33tlabs.twl</groupId>
        <artifactId>pngdecoder</artifactId>
        <version>1.0</version>
    </dependency>
</dependencies>
<build>
    <finalName>game-imgui</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                <manifest>
                    <mainClass>org.example.Main</mainClass>
                </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

`

I can build the fat jar with mvm package. On my linux dev machine it works fine using :

java -jar game-imgui-jar-with-dependencies.jar

But running the same command on windows 10 gives the error :

eim

I think it has relation with the load of native code on /windows subdirectory.. I tried some advice like https://stackoverflow.com/questions/12036607/bundle-native-dependencies-in-runnable-jar-with-maven but without success.

Relevant log output

No response

enesaltinkaya commented 1 year ago

I think you need add natives-windows dependency.

<dependency>
    <groupId>io.github.spair</groupId>
    <artifactId>imgui-java-natives-windows</artifactId>
    <version>1.86.10</version>
</dependency>