Access restriction on class due to restriction on required library rt.jar?

前端 未结 15 1734
忘掉有多难
忘掉有多难 2020-11-22 01:09

I\'m attempting to compile Java 1.4 code that was created by IBM\'s WSDL2Java on Java5 without recreating

相关标签:
15条回答
  • 2020-11-22 01:33

    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.

    0 讨论(0)
  • 2020-11-22 01:35

    There's another solution that also works.

    1. Go to the Build Path settings in the project properties.
    2. Remove the JRE System Library
    3. Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.

    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

    0 讨论(0)
  • 2020-11-22 01:38

    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.

    0 讨论(0)
提交回复
热议问题