This repository provides a simple example demonstrating how to build a cross-platform Java JAR package that encapsulates JNI shared libraries for Windows, Linux, and macOS, binding to the Dynamsoft C++ Barcode Reader SDK. For using production-ready Java barcode detection API, please download the official Java Barcode SDK directly.
<repositories>
<repository>
<id>dbr </id>
<url>
https://download2.dynamsoft.com/maven/dbr/jar
</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.dynamsoft</groupId>
<artifactId>dbr</artifactId>
<version>9.6.40.1</version>
</dependency>
</dependencies>
Obtain a 30-day free trial license.
Navigate to your Java source directory and generate the JNI header file:
cd src/main/java
javah -o ../../../jni/NativeBarcodeReader.h com.dynamsoft.barcode.NativeBarcodeReader
mkdir build
cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
cmake --build . --config Release --target install
mkdir build
cd build
cmake ..
cmake --build . --config Release --target install
mvn package
-
Set the license key in
Test.java
:barcodeReader.setLicense("LICENSE-KEY");
-
Run the test:
java -cp target/barcode-1.0.0.jar Test.java <image file>