I have two classes X and Y in the same package.
In class X there is import org1.A
In class Y , there is import org2.A
and also A.somemethod()
.
During runtime I am getting NoClassDefFoundError when A.somemethod()
is called. What could be the reason for this?
I earlier thought that maybe instead of using class A
from org2
, JVM is trying to use class A
from org1
, but I am not fully sure as to why and how this is happening. Is there any use of import statements at runtime?
Check org1.A and org2.A both classers added to class path or not, at run time compiler will try to refer the class which was imported in your src file.
Check org1.A and org2.A both are compiled and generated .class file for thise in target dir.
For more exact answer, you better your code snippet.
Hope this helps, upvote if it helps.