How to Build Desktop Barcode Scanner in Java and Kotlin

Dynamsoft provides Java Barcode SDKs for both mobile and desktop development. The mobile edition is distributed as an Android AAR package, and the desktop edition is distributed as a JAR package. This article aims to help developers who want to build desktop or server-side barcode scanner applications in Java or Kotlin.

Installing Dynamsoft Barcode Reader via Gradle

To get Dynamsoft Barcode Reader, you can either download the SDK directly or configure the Maven URL for auto-build tools. I recommend using Gradle to create a Java or Kotlin barcode scanner project.


Create a new Gradle project:

Go to app > build.gradle to add the Maven repository hosted by Dynamsoft and the dependency:

Note: for building Android barcode scanner projects, the URL and the package name are different:

Java Barcode Scanner Application for Windows, Linux, and macOS

Dynamsoft Java Barcode SDK is implemented in Java Native Interface (JNI). Therefore, it brings better performance than pure Java SDKs, such as ZXing. Although the underlying technology is C++, the SDK has wrapped native libraries for multiple operating systems.

We can open or App.kt files to instantiate the barcode reader object as follows:

Click here to get a 30-day FREE Trial License if you want to unlock all API functionalities.

Dynamsoft allows developers to custom algorithms for specific scenarios. So we can visit the free barcode online demo to generate an appropriate template for parameter initialization:

The following sample code is used to read barcodes from an image file and print out all results:

With a few lines of code, a simple command-line barcode scanner is done.

Here is a blurred QR code image:

We can now run the Gradle command with specified arguments.

Testing Java Applications Using Travis CI

To verify whether the bar code scanner application is cross-platform, we create a .travis.yml file for the GitHub repository:

We have to add ‘ chmod +x' to make the gradlew script file work on Linux and macOS.

Source Code

Originally published at on March 8, 2021.

Manager of Dynamsoft Open Source Projects | Tech Lover