AuthorizeNet/sdk-java

error: package javax.xml.bind.annotation does not exist

AndyNicholls opened this issue · 4 comments

I am trying to build the jar files using ant on windows 10. I am getting the message 'error: package javax.xml.bind.annotation does not exist'. Searching the net indicates this package is no longer shipped with the java SE JDK. I am using ant to build. Stackoverflow suggest adding the --add-modules java.xml.bind compiler option, but I could not get this to work with ant . I have seen some work-arounds by updating the pom.xml file, but I am not using maven.

I also had an issue with log4j not found. I fixed this by adding log4j to the .classpath file.

Apache Ant(TM) version 1.9.15 compiled on May 10 2020
JAVA_HOME=C:\Program Files\Java\jdk-15

C:\Users\andrewn\Documents\Personal\sdk-java-master>ant jar
Buildfile: C:\Users\andrewn\Documents\Personal\sdk-java-master\build.xml

compile:
[javac] Compiling 332 source files to C:\Users\andrewn\Documents\Personal\sdk-java-master\target\classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 8
[javac] C:\Users\andrewn\Documents\Personal\sdk-java-master\src\main\java\net\authorize\api\contract\v1\ANetApiRequest.java:11: error: package javax.xml.bind.annotation does not exist
[javac] import javax.xml.bind.annotation.XmlAccessType;
[javac] ^
[javac] C:\Users\andrewn\Documents\Personal\sdk-java-master\src\main\java\net\authorize\api\contract\v1\ANetApiRequest.java:12: error: package javax.xml.bind.annotation does not exist
[javac] import javax.xml.bind.annotation.XmlAccessorType;
[javac] ^
[javac] C:\Users\andrewn\Documents\Personal\sdk-java-master\src\main\java\net\authorize\api\contract\v1\ANetApiRequest.java:13: error: package javax.xml.bind.annotation does not exist
[javac] import javax.xml.bind.annotation.XmlElement;
[javac] ^
[javac] C:\Users\andrewn\Documents\Personal\sdk-java-master\src\main\java\net\authorize\api\contract\v1\ANetApiRequest.java:14: error: package javax.xml.bind.annotation does not exist
[javac] import javax.xml.bind.annotation.XmlSeeAlso;
[javac] ^
[javac] C:\Users\andrewn\Documents\Personal\sdk-java-master\src\main\java\net\authorize\api\contract\v1\ANetApiRequest.java:15: error: package javax.xml.bind.annotation does not exist
[javac] import javax.xml.bind.annotation.XmlType;

Hi,

Thank you for reaching out to us about this.

Unfortunately, the Java version for this code is capped at JDK 1.8 (which has LTS till 2030). JDK >=1.9 has made changes to the JRE which has removed some of these imports which were originally part of the JRE.

Kindly downgrade the JDK to 1.8 (or Java 8).

We are facing the exact issue with Java 11.

switch to 1.8.0_261 as 1.8.271.09 gives issues

I don't want to downgrade to 1.8. What is the fix for Java 17?