During Java 9 module based development when module path contains two documents of same name when we start loading of module at time loader can not load module because of more than one module of same name.

java.lang.module.FindException: Two versions of module javadeveloperzone.base found in output\mlib (javadevelo
perzone.base.jar and base.jar)
        at jdk.internal.module.ModulePath.scanDirectory([email protected]/Unknown Source)
        at jdk.internal.module.ModulePath.scan([email protected]/Unknown Source)
        at jdk.internal.module.ModulePath.scanNextEntry([email protected]/Unknown Source)
        at jdk.internal.module.ModulePath.find([email protected]/Unknown Source)
        at java.lang.module.ModuleFinder$2.lambda$find$0([email protected]/Unknown Source)
        at java.util.stream.ReferencePipeline$3$1.accept([email protected]/Unknown Source)
        at java.util.AbstractList$RandomAccessSpliterator.tryAdvance([email protected]/Unknown Source)
        at java.util.stream.ReferencePipeline.forEachWithCancel([email protected]/Unknown Source)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel([email protected]/Unknown Source)
        at java.util.stream.AbstractPipeline.copyInto([email protected]/Unknown Source)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto([email protected]/Unknown Source)
        at java.util.stream.FindOps$FindOp.evaluateSequential([email protected]/Unknown Source)
        at java.util.stream.AbstractPipeline.evaluate([email protected]/Unknown Source)
        at java.util.stream.ReferencePipeline.findFirst([email protected]/Unknown Source)
        at java.lang.module.ModuleFinder$2.find([email protected]/Unknown Source)
        at java.lang.module.Resolver.findWithBeforeFinder([email protected]/Unknown Source)
        at java.lang.module.Resolver.resolve([email protected]/Unknown Source)
        at java.lang.module.Configuration.resolveAndBind([email protected]/Unknown Source)
        at java.lang.module.ModuleDescriptor$1.resolveAndBind([email protected]/Unknown Source)
        at jdk.internal.module.ModuleBootstrap.boot([email protected]/Unknown Source)
        at java.lang.System.initPhase2([email protected]/Unknown Source)


Java 9 Module can not allowed two module with same name in your module path so solve this problem:

  1. Find out which modules have same name and rename it
  2. Find our which modules have same name and remove duplicate modules

Note:If your rename jar files which doesn’t means that you rename module name to rename module go to module-info.java file and update name over there and recompile your module and create jar file so your problem will be solve.


Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.

Leave a Reply

Your email address will not be published. Required fields are marked *