AvaTax SDK JRE

These libraries are open source and are released as such. If you have located a bug or have questions, please visit the GitHub repositories that are associated with the sample code and provide feedback there.
Latest SDK version 23.4.1
Installation

The AvaTax JRE SDK is available for download on Maven.

For the AvaTax JRE SDK, there are 4 different files available to download:

  • pom: This Project Object Model is an XML file that contains information about the project and configuration details used by Maven to build the project. This file is not needed in order to run the AvaTax JRE SDK.
  • jar: This is the file that you will import into your project to access AvaTax. This file is needed in order to run the AvaTax JRE SDK.
  • javadoc.jar: This file is the documentation generated from the source code in the JAR file. This file is not needed in order to run the AvaTax JRE SDK.
  • sources.jar: This file contains the source code for the JAR file. This file is not needed in order to run the AvaTax JRE SDK, but it is helpful to use in order to view the code within the JAR file in the editor. To view the code, download this file and attach it as a source to the JAR file. Once you have the JAR file downloaded, import it into your editor as an external JAR file.
Using the JRE SDK

The JRE SDK uses a fluent interface to define a connection to AvaTax and to make API calls to calculate tax on transactions. Here's an example of how to connect to AvaTax in Java:

View Example
Updates

Two functions have been updated in 19.9.1

    downloadTaxRatesByZipCodeAsync(Date date, String region)
     downloadTaxRatesByZipCodeAsync(Date date, String region)    

have been changed to

    downloadTaxRatesByZipCodeAsync(String date, String region)
     downloadTaxRatesByZipCodeAsync(String date, String region)
How to enable logging in SDK
  • The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks.
  • The client would need to implement the SLF4J provider (or binding) on their end like Log4j, Logback, and so on to enable logging.
  • By default, there is no logging enabled.
  • All the attributes which are part of log messages are in LogObject.java
  • To enable or disable logging of request and response objects, there is a boolean variable shouldLogRequestAndResponse in AvataxConstants. The default is set to FALSE.
  • The output of logging is in JSON format.

The following example shows how logging could be enabled on client side using Log4j.

  • In build.sbt or pom.xml, we would add the following changes:
// build.sbt 
"org.slf4j" % "slf4j-log4j12" % "2.0.1"

//pom.xml 
<dependency> 
	<groupId>org.slf4j</groupId>
	 <artifactId>slf4j-log4j12</artifactId> 
	 <version>2.0.1</version> 
</dependency> 
  • Make sure to refresh the project to get the latest dependencies.
  • Under the src -> main -> resources folder, create a log4j.properties file and add the configurations which would cater your needs. For example:
 log4j.rootLogger=INFO, STDOUT
 log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
 log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
 log4j.appender.STDOUT.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

Please note that the log4j.properties (or any other configuration) file could contain a variety of configurations such as adding logs to a log file, constructing the log file name, and so on.

The current example shows the configuration to display logs at console only.