I\'m attempting to compile Java 1.4 code that was created by IBM\'s WSDL2Java on Java5 without recreating
Go to the Java Build Path in the project properties. Remove the existing JRE System Library Then Add it again i.e. Add Library-->JRE Lib--select jre--->Finish. Lastly select order and export tab select JRE Lib and move on top. That's it.
There's another solution that also works.
This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first. If you want a fundamental solution make sure you exclude the jar files with the same classes.
For me I have: javax.xml.soap.SOAPPart
in three different jars: axis-saaj-1.4.jar
, saaj-api-1.3.jar
and the rt.jar
In the case you are sure that you should be able to access given class, than this can mean you added several jars to your project containing classes with identical names (or paths) but different content and they are overshadowing each other (typically an old custom build jar contains built-in older version of a 3rd party library).
For example when you add a jar implementing:
a.b.c.d1
a.b.c.d2
but also an older version implementing only:
a.b.c.d1
(d2 is missing altogether or has restricted access)
Everything works fine in the code editor but fails during the compilation if the "old" library overshadows the new one - d2 suddenly turns out "missing or inaccessible" even when it is there.
The solution is a to check the order of compile-time libraries and make sure that the one with correct implementation goes first.