0

I have an application that has an Abstract class defined. The jar file of this application is, lets say,

application.jar

I have another application which has implementations for the Abstract class defined in application.jar. This application is exported as Implementation.jar

I have used Java Serviceloader to load the class from Implementation.jar

ServiceLoader<MyInterface> services1 = ServiceLoader.load(MyInterface.class);
        MyInterface myinf = services1.iterator().next();
        myinf.myMessage();

And ran the jar file using

java -cp Application.jar;Implementation.jar <MyMain Class here>

I am facing the following issue

java.lang.ClassNotFoundException: com.dummy.controller.MyInterface
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_181-1-ojdkbuild]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_181-1-ojdkbuild]

Please help me understand the issue here and which classloader to use to resolve the issue.

Ram
  • 11
  • 3

0 Answers0