I am new to java so not sure I fully understand jar files.
I want to put some common code in a library jar, which I then use from applications that are in different jars
If the Class-Path attribute of the manifest of the application jar file is
mylibrary-0.0.1-SNAPSHOT.jar
and the two jar files are in the same directory, then running
java -jar myapp-0.0.1-SNAPSHOT.jar should work.
You can also set the classpath explicitely, and set the main class explicitely, which is much easier, and doesn't rely on relative paths in the manifest.
java -cp myapp-0.0.1-SNAPSHOT.jar:mylibrary-0.0.1-SNAPSHOT.jar org.myorg.myapp.Main
You should not use the -classpath and the -jar options in the same command. It's one or the other.