Home >Java >javaTutorial >Why Does My Java 1.4 Code Fail to Compile Due to rt.jar Access Restrictions?
Java class access restriction due to rt.jar dependency
When attempting to compile Java 1.4 code with outdated stubs generated by WSDL2Java, developers may encounter an access restriction error. This error stems from the inaccessibility of the QName type due to a limitation on the rt.jar library. While the assumption is that stubs should compile with runtime jars available, this issue arises when there are duplicate classes in multiple jar files.
Solution:
To resolve this issue, follow these steps:
This will prioritize the correct version of the class in the rt.jar file, allowing access to the QName type.
Alternative Solution:
To address the underlying problem, identify and exclude any jar files containing duplicate classes. This ensures that the correct version of the class is loaded and used by the compiler. In the example provided, the duplicate class is javax.xml.soap.SOAPPart found in multiple jars. Excluding the axis-saaj-1.4.jar and saaj-api-1.3.jar files will allow the rt.jar version to be utilized, resolving the access restriction.
The above is the detailed content of Why Does My Java 1.4 Code Fail to Compile Due to rt.jar Access Restrictions?. For more information, please follow other related articles on the PHP Chinese website!