0

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.

swhite
  • 471
  • 1
  • 6
  • 11
  • "NoClassDefFoundError: com/project/Class A" - a class named `Class`? and what's that 'A' separated by a blank in that message? – P.J.Meisch Feb 08 '19 at 06:57
  • hmm I don't like the fact that I can't add the answer now that it has been marked a duplicate. Oh well, loss for the community. – swhite Feb 08 '19 at 16:59
  • @P.J.Meisch A bad example of sudo code. In this case it should have just been called A. – swhite Feb 08 '19 at 17:56

0 Answers0