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(java.base@9-ea/Unknown Source) at jdk.internal.module.ModulePath.scan(java.base@9-ea/Unknown Source) at jdk.internal.module.ModulePath.scanNextEntry(java.base@9-ea/Unknown Source) at jdk.internal.module.ModulePath.find(java.base@9-ea/Unknown Source) at java.lang.module.ModuleFinder$2.lambda$find$0(java.base@9-ea/Unknown Source) at java.util.stream.ReferencePipeline$3$1.accept(java.base@9-ea/Unknown Source) at java.util.AbstractList$RandomAccessSpliterator.tryAdvance(java.base@9-ea/Unknown Source) at java.util.stream.ReferencePipeline.forEachWithCancel(java.base@9-ea/Unknown Source) at java.util.stream.AbstractPipeline.copyIntoWithCancel(java.base@9-ea/Unknown Source) at java.util.stream.AbstractPipeline.copyInto(java.base@9-ea/Unknown Source) at java.util.stream.AbstractPipeline.wrapAndCopyInto(java.base@9-ea/Unknown Source) at java.util.stream.FindOps$FindOp.evaluateSequential(java.base@9-ea/Unknown Source) at java.util.stream.AbstractPipeline.evaluate(java.base@9-ea/Unknown Source) at java.util.stream.ReferencePipeline.findFirst(java.base@9-ea/Unknown Source) at java.lang.module.ModuleFinder$2.find(java.base@9-ea/Unknown Source) at java.lang.module.Resolver.findWithBeforeFinder(java.base@9-ea/Unknown Source) at java.lang.module.Resolver.resolve(java.base@9-ea/Unknown Source) at java.lang.module.Configuration.resolveAndBind(java.base@9-ea/Unknown Source) at java.lang.module.ModuleDescriptor$1.resolveAndBind(java.base@9-ea/Unknown Source) at jdk.internal.module.ModuleBootstrap.boot(java.base@9-ea/Unknown Source) at java.lang.System.initPhase2(java.base@9-ea/Unknown Source)
Solution:
Java 9 Module can not allowed two module with same name in your module path so solve this problem:
- Find out which modules have same name and rename it
- 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. That’s the only way we can improve.