0

Edit: The same issue happens even when packaging without Maven via intelliJ, see here. JDK I built the project in and my environment variables are both Amazon Corretto 11. I'm not able to get a stacktrace because the program works perfectly through cmd. This issue only happens when trying to click to open the jar

I've spent all day trying to package my Maven project. I've been trying to use the maven-assembly-plugin. I believe I've followed this and this respectively, though it's possible I missed something. My entire pom.xml is here, as I'm guessing the answer will lie there.

The exact errors I get when trying to run the jars via clicking are: "Error: A JNI error has occurred, please check your installation and try again" followed by "A Java Exception has occurred". The code runs fine when launched through my IDE and definitely doesn't throw a compile time exception as it appears to be doing when running as a jar.

<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>ScraperTest</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>Main</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                        <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>




    <dependencies>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.13.1</version>
        </dependency>

        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.32.3.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.11</version>
        </dependency>


    </dependencies>


    
</project> 
Patrick
  • 39
  • 1
  • 6
  • Please add JDK version, Maven versions you are using also the output of the build including the full error output ... cause you have not defined the version of maven-assembly-plugin? – khmarbaise Nov 15 '20 at 10:35
  • JDK is 11, Amazon Corretto. The build completes with no errors. I defined the version as 3.3.0, re-built, and got the same error. It's worth noting that the same issue happens even if I'm not packaging with Maven, which I discovered after this post. It's also worth noting that the program works fine when using -jar in cmd, the issue only happens when trying to open the jar via clicking. – Patrick Nov 15 '20 at 10:41

0 Answers0