For reasons outside the scope of this question I have two jars.
Jar1: project/project.jar
which is a spring-boot jar and contains class A.
Jar2: mock/project-mock.jar
which is a jar that contains class B.
project-mock.jar
does not have a main class and is not meant to be ran standalone.
Class B extends Class A.
I'm trying to run these jars together using the following command
java -cp project/project.jar:mock/project-mock.jar org.springframework.boot.loader.JarLauncher
When I run the above command the spring boot jar starts initializing but then I get an exception:
problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: com/project/Class A
Is this an issue relating to how I am trying to start the application or how do I fix the classpath issue to correctly set the jars on the same classpath?
Edit: I don't believe this is the same issue as Why am I getting a NoClassDefFoundError in Java? since adding the two jars on the command line would put them on the same classpath, i thought. If that is not the case then that would be the issue but I would like to know why then so I can fix it. Edit on the Edit: Looking further into the exception thrown there is a nested exception java.lang.ClassNotFoundException which brings me back to the classpath issue rather than the class not correctly loading the first time.