Pure Kotlin SMB2/SMB3 Client Library

A modern SMB client library for Kotlin, Java, and Android. Connect to Windows file shares, Samba, and NAS devices with a coroutine-based, type-safe API.

Main.kt
SmbClient.connect("fileserver", NtlmCredentials("user", "pass"), config = config).use { client ->
    client.connectShare("documents").use { share ->
        share.listDirectory("/").collect { file ->
            println("${file.name} (${file.size} bytes)")
        }
    }
}

A complete SMB client library for Kotlin and Java

Built from the ground up in Kotlin with modern APIs and zero native dependencies. Works with Windows, Samba, and any SMB2/SMB3 server.

smb-kotlin architecture: Pure Kotlin SMB2/SMB3 client connecting to Windows Server, Samba, and NAS devices with no JNI dependencies
smb-kotlin architecture — pure Kotlin, no native dependencies

Pure Kotlin

No JNI, no native dependencies. Runs anywhere the JVM runs — desktop, server, or Android.

SMB2 & SMB3

Full SMB2 and SMB3 protocol support with automatic version negotiation. Compatible with Windows Server, Samba, and NAS devices.

AES-128-CCM Encryption

Secure connections with SMB3 encryption, automatic or forced.

Coroutines & Flow

Async-first API built on Kotlin Coroutines. Directory listings are cold Flows.

Streaming I/O

Read and write files of any size via Okio streaming. No memory limits.

Android Ready

The only pure-Kotlin SMB client for Android. Works on API 26+ out of the box, tested on real devices.

Custom Transport

Plug in any Socket implementation. Built-in support for BlackBerry Dynamics.

Server-Side Copy

Copy files on the server without transferring data through your app.

Kotlin SMB client API examples

Real working code from the developer guide. Connect to SMB shares, read and write files — all with idiomatic Kotlin. Also works from Java.

Connect and List Files
val license = SmbLicense.fromStream(
    MyApp::class.java.getResourceAsStream("/smb.lic")!!
)
val config = SmbConfig(license = license)

SmbClient.connect(
    "nas.local",
    NtlmCredentials("alice", "secret"),
    config = config
).use { client ->
    client.connectShare("shared").use { share ->
        share.listDirectory("documents").collect { entry ->
            val type = if (entry.isDirectory) "DIR " else "FILE"
            println("$type ${entry.name} (${entry.size} bytes)")
        }
    }
}
Upload a File
share.writeFile("reports/quarterly.pdf") { sink ->
    val bufferedSink = sink.buffer()
    File("quarterly.pdf").source().buffer().use { src ->
        bufferedSink.writeAll(src)
    }
    bufferedSink.flush()
}
Android ViewModel
class FileViewModel(private val app: Application) : AndroidViewModel(app) {
    fun loadFiles(host: String, user: String, pass: String) {
        viewModelScope.launch(Dispatchers.IO) {
            val license = SmbLicense.fromStream(app.assets.open("smb.lic"))
            val config = SmbConfig(license = license)
            SmbClient.connect(host, NtlmCredentials(user, pass), config = config).use { client ->
                client.connectShare("documents").use { share ->
                    val files = share.listDirectory("/").toList()
                    // Update UI state
                }
            }
        }
    }
}

Java SMB library comparison

See how smb-kotlin compares to smbj and jcifs-ng — the other JVM SMB client libraries.

Feature smb-kotlin smbj jcifs-ng
Language Kotlin Java Java
API Style Coroutines + Flow Blocking / CompletableFuture Blocking
SMB3 Encryption
Android Support Partial Partial
Streaming I/O
Custom Socket Transport
Server-Side Copy
Kotlin-First API
Active Maintenance Limited

Simple, transparent pricing

Choose the plan that fits your team. All plans include the full library with every feature.

Solo

$299 /year

1 developer license

  • 1 developer seat
  • 1 year of updates
  • Email support
Buy Now
Most Popular

Team

$999 /year

5 developer licenses

  • 5 developer seats
  • 1 year of updates
  • Priority email support
Buy Now

Enterprise

Custom

Unlimited developers

  • Unlimited developers
  • Custom terms
  • Dedicated support
Contact Us

All purchases are subject to the License Agreement. Software is provided as-is.

Frequently asked questions about smb-kotlin

What platforms are supported?
JVM 17+ and Android API 26+ (Android 8.0). Works on Windows, macOS, Linux, and Android.
Which SMB servers are compatible?
Any server supporting SMB2 or SMB3: Windows Server, Samba, NAS devices (Synology, QNAP), macOS file sharing, and cloud storage gateways.
Does smb-kotlin work with Samba servers?
Yes. smb-kotlin is fully compatible with Samba, the open-source SMB/CIFS implementation for Linux and Unix. It supports the SMB2 and SMB3 protocols used by modern Samba deployments.
Can I use smb-kotlin from Java?
Yes. smb-kotlin is a standard JVM library that works with any JVM language including Java, Kotlin, and Scala. It is a modern alternative to Java SMB libraries like smbj and jcifs-ng, with full SMB3 encryption support and a streaming I/O API.
Is there an SMB client library for Android?
Yes. smb-kotlin is the only pure-Kotlin SMB client library for Android. It works on API 26+ with no native dependencies and provides a coroutine-based API that integrates naturally with ViewModels and lifecycle-aware components.
Do I need an internet connection for the license?
No. Licenses are validated offline using Ed25519 digital signatures. No phone-home or activation server required.
What happens when my license expires?
The library will throw an SmbLicenseException on connect. Renew your license to continue using the library. Your existing code does not need to change.
Can I upgrade from Solo to Team?
Yes. Contact us and we'll apply your existing payment as credit toward the Team license.
Is source code included?
No. smb-kotlin is distributed as an obfuscated .jar. Full API documentation is provided.
Is there a free trial?
Yes. Fill out the trial request form below and we'll send you a 7-day evaluation license.

Try smb-kotlin free for 7 days

Fill out the form and we'll send you a 7-day trial license within 24 hours.

Need help?

For sales inquiries, technical support, or custom licensing, reach out and we'll get back to you within one business day.

support@ctreesoft.com