I have been working on my first sharp project for the last month and I am a newbie on java. Everything has worked out fine running the application in vs code using maven and some external dependencies and I have also referenced a local api.jar file as a maven dependency. Now I am at the stage where I am about to package the application and I want to create a jar file that includes my whole project and all dependencies. I now spent a whole day trying to find a solution to this and it seems ridiculously complicated comparing to more modern languages.
I have finally landed in using the maven-assembly plugin (not sure if this is the best choice) but after hours of googeling this seemed to be the best choice to achieve this.
Pressing the "package" button in vs code renders a jar-with-dependencies.jar with success but when running it with "java -jar nameojar.jar it can not find
classes from local dependency api.jar (even though the project runs inside vs code) "main" java.lang.NoClassDefFoundError: pico/db/DBException
I previously had other local jars that gave the same error type but changing to normal remote dependencies solved it and I am pretty sure the error comes from the last local jar not being included in the final jar. The only local jar that is left is unfortunately is an api that only exits as jar and not as a remote maven dep.
How can I get this jar into my final jar?
(changed names here for customer privacy so dont mind name typos if any)
____ POM FILE___
Thanks<?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>se.ax</groupId> <artifactId>ax</artifactId> <version>1.0</version> <repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories> <properties> <maven.compiler.source>21</maven.compiler.source> <maven.compiler.target>21</maven.compiler.target> <vapipath>/home/mikael/.m2/repository/vapi/ax/5.0.4/ax-5.0.4.jar</vapiapath> <tinylogapipath>/home/mikael/.m2/repository/tinylogapi/ax/2.7.0/ax-2.7.0.jar</tinylogapipath> --> </properties> <dependencies> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <version>9.0.0</version> </dependency> <dependency> <groupId>com.github.Carleslc.Simple-YAML</groupId> <artifactId>Simple-Yaml</artifactId> <version>1.8.4</version> </dependency> <dependency> <groupId>org.tinylog</groupId> <artifactId>tinylog-api</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>org.tinylog</groupId> <artifactId>tinylog-impl</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>vakaapi</groupId> <artifactId>ax</artifactId> <version>0.0.0</version> <scope>system</scope> <systemPath>${vakaapipath}</systemPath> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>ax.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> </project>