Skip to main content

Java quick start for the Linux Document Scanner SDK

Build a lightweight document scanner in Java for Linux.

Create the project and install the Scanbot SDK​

1. Init Java project with Gradle​

mkdir document-quickstart-java
cd document-quickstart-java
gradle init --type java-application

2. Add the Scanbot SDK to build.gradle​

Replace <SCANBOT_SDK_VERSION> with the version you want to install.

import java.net.URL
import java.io.FileOutputStream

val scanbotSdkVersion = "<SCANBOT_SDK_VERSION>"
val arch = System.getProperty("os.arch")
val scanbotArch = if (arch.contains("arm") || arch.contains("aarch64")) "aarch64" else "x86_64"

fun urlFile(url: String, name: String) = run {
val file = layout.buildDirectory.dir("libs").get().file(name).asFile
file.parentFile.mkdirs()
if (!file.exists()) {
URL(url).openStream().use { input ->
FileOutputStream(file).use { output ->
input.copyTo(output)
}
}
}
files(file.absolutePath)
}

dependencies {
implementation(
urlFile(
"https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv$scanbotSdkVersion/scanbotsdk-$scanbotSdkVersion-linux-$scanbotArch.jar",
"scanbotsdk.jar"
)
)
}

Project layout​

Replace src/main/java/org/example/App.java with your quick-start code.

Initialize the Scanbot SDK​

Before using any feature of the Scanbot SDK, initialize the SDK with your license key.

import io.scanbot.sdk.ScanbotSDK;
import io.scanbot.sdk.licensing.LicenseInfo;

final String LICENSE_KEY = "SCANBOTSDK-LICENSE";
final String WRITABLE_PATH = System.getProperty("user.dir");

ScanbotSDK.initialize(LICENSE_KEY, WRITABLE_PATH);
LicenseInfo info = ScanbotSDK.getLicenseInfo();
System.out.printf("License status=%s%n", info.getStatus());

Scan a document image​

The following snippet scans a document from an image.

scan document from ImageRef
loading...

Run​

./gradlew run --args='/path/to/document_image.jpg'

Get in touch​

If you need further information or are interested in licensing the Scanbot SDK, please get in touch with our solution experts.