Chilkat for B4X
native Chilkat classes for B4A (Android) and B4J (Windows, Linux, macOS)
B4A: Android 7.0+ (minSdkVersion 24), armeabi-v7a, arm64-v8a, x86, and x86_64 ·
B4J: Windows x64, Linux x86_64 / arm64 / arm (armv7l), and macOS (Intel and Apple Silicon).
Chilkat for B4X provides two libraries built from the same source: ChilkatB4A for Android and
ChilkatB4J for desktop and server applications. Each Chilkat class appears in the IDE as a regular B4X
type with a Chilkat prefix — ChilkatHttp, ChilkatCrypt2,
ChilkatZip, ChilkatJsonObject, … — with full autocomplete and inline
documentation, and the API is identical in B4A and B4J, so code moves between them unchanged. The jars are
self-contained: the native Chilkat library for every supported CPU rides inside the jar, is packaged into your
APK automatically on Android, and is loaded automatically on the desktop. Nothing is installed or registered
on your machine: copy two files into the IDE's additional-libraries folder and go.
Download
This is the full-version Chilkat product. Chilkat libraries are fully functional for a 30-day evaluation; no separate trial build is required. One download covers both B4A and B4J, with the native libraries for every supported platform included.
The 60-second version
- Unzip the download.
- Copy
ChilkatB4A.jar+ChilkatB4A.xmlinto B4A's additional libraries folder, and/orChilkatB4J.jar+ChilkatB4J.xmlinto B4J's additional libraries folder. - In the IDE's Libraries Manager tab, check ChilkatB4A (or ChilkatB4J), paste the QuickStart code below, and run.
That's the whole setup: two files in the additional-libraries folder, one checkbox. The rest of this page fills in the details.
Documentation & Samples
- 📖 Chilkat B4X Reference Documentation
- 💻 Chilkat B4X Sample Code — ready-to-run examples
- 📝 Release Notes on the Chilkat blog
What's in the download
Unzipping creates a chilkat-b4x directory containing both libraries:
| File | Description |
|---|---|
ChilkatB4A.jar | The B4A library: all Chilkat classes plus the native
libchilkat_b4x.so for each of the four Android ABIs (armeabi-v7a, arm64-v8a, x86, x86_64).
The B4A compiler packages the matching native libraries into your APK automatically — there is nothing
to deploy by hand. The 64-bit libraries are 16 KB-page-aligned, as required by Google Play for apps
targeting Android 15+. |
ChilkatB4A.xml | The library metadata the B4A IDE reads for the Libraries Manager, autocomplete, and inline documentation. Always keep it in the same folder as the jar. |
ChilkatB4J.jar | The B4J library: the same Chilkat classes plus the native library for each desktop platform — Windows x64, Linux x86_64 / arm64 / arm, and macOS arm64 (Apple Silicon) and x86_64 (Intel). At runtime the library detects the platform, extracts the matching binary to a per-version cache directory, and loads it — no manual native deployment (see How the native library is loaded). |
ChilkatB4J.xml | The library metadata for the B4J IDE. Keep it beside
ChilkatB4J.jar. |
license.pdf | The full EULA license agreement. |
Using Chilkat in your own project
- Install the library. Copy the jar + xml pair into the IDE's additional libraries folder. If you haven't configured one yet, set it under Tools → Configure Paths → Additional libraries folder (B4A and B4J each have their own). Restart the IDE, or right-click the Libraries Manager and choose Refresh, and ChilkatB4A / ChilkatB4J appears in the list.
- Check the library in the Libraries Manager tab. Every Chilkat class is now available with
autocomplete: type
Chilkatand the full list appears. - Declare and initialize. Chilkat objects are declared like any other B4X object. Classes with
progress events take an event-name prefix in
Initialize; the rest take no arguments:Sub Process_Globals Private glob As ChilkatGlobal Private crypt As ChilkatCrypt2 ' has AbortCheck / PercentDone / ProgressInfo events End Sub - Write some code. Here is a complete QuickStart: it unlocks Chilkat, AES-encrypts a string, and
decrypts it again. In B4J, call it from
AppStart; in B4A, fromActivity_Create. The code itself is identical in both.Sub ChilkatQuickStart ' Unlock Chilkat once at application startup. ' Any string unlocks a fully-functional 30-day trial. glob.Initialize If glob.UnlockBundle("Anything for 30-day trial") = False Then Log(glob.LastErrorText) Return End If ' AES-256 in CBC mode, hex-encoded output. crypt.Initialize("crypt") crypt.CryptAlgorithm = "aes" crypt.CipherMode = "cbc" crypt.KeyLength = 256 crypt.PaddingScheme = 0 crypt.EncodingMode = "hex" crypt.SetEncodedIV("000102030405060708090A0B0C0D0E0F", "hex") crypt.SetEncodedKey("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F", "hex") Dim encStr As String = crypt.EncryptStringENC("The quick brown fox jumps over the lazy dog.") Log("Encrypted: " & encStr) Log("Decrypted: " & crypt.DecryptStringENC(encStr)) End Sub - Run it. The encrypted hex string and the decrypted text appear in the log.
UnlockBundle once at application startup rather than in every Sub. Once
unlocked, every Chilkat class in the process remains unlocked for the life of the application.
Progress monitoring and aborting
All Chilkat methods are synchronous: the call returns when the work is done. Classes that perform
potentially long-running work (ChilkatHttp, ChilkatSFtp, ChilkatZip,
ChilkatCrypt2, ChilkatMailMan, …) raise three events during the call, so your
application can show progress and offer a way out. The event-name prefix is the string you passed to
Initialize.
Here is a complete example that demonstrates all three events. It builds a zip in memory from string
entries and writes it to a ChilkatBinData — the compression happens inside
WriteBd, and that call raises the zip_* events below while it runs:
Sub Process_Globals
Private zip As ChilkatZip
Private bd As ChilkatBinData
End Sub
Sub ZipWithProgress
zip.Initialize("zip") ' "zip" is the event-name prefix for the Subs below
zip.HeartbeatMs = 100 ' raise zip_AbortCheck every 100 ms during Chilkat calls
zip.NewZip("demo.zip") ' begins a new zip; nothing is written until a Write* call
' Add entries from strings. Entries accumulate in the zip object;
' no compression happens yet.
Dim big As StringBuilder
big.Initialize
For i = 1 To 2000
big.Append("Line ").Append(i).Append(": The quick brown fox jumps over the lazy dog.").Append(CRLF)
Next
zip.AddString("readme.txt", "Hello from Chilkat for B4X!", "utf-8")
zip.AddString("data/big.txt", big.ToString, "utf-8")
' Write the zip to an in-memory BinData. This is where the entries are
' compressed, and this call raises the zip_* events while it runs.
bd.Initialize
If zip.WriteBd(bd) = False Then
Log(zip.LastErrorText)
Return
End If
Log("Zip created in memory: " & bd.NumBytes & " bytes")
End Sub
Sub zip_AbortCheck As Boolean
Log("AbortCheck")
Return False ' return True to abort the write
End Sub
Sub zip_PercentDone (PctDone As Int) As Boolean
Log("PercentDone: " & PctDone & "%")
Return False ' return True to abort
End Sub
Sub zip_ProgressInfo (Name As String, Value As String)
Log("ProgressInfo: " & Name & " = " & Value)
End Sub
AbortCheck fires at regular intervals controlled by the object's HeartbeatMs
property (0, the default, disables it); PercentDone fires when an operation's completion
percentage is known and can also abort; ProgressInfo delivers named progress values. Implement
only the Subs you need — the events are skipped entirely when no matching Sub exists.
If you run a Chilkat call on a separate thread (e.g. with the Threading library), its events are
automatically queued to the main thread. Events raised that way can't abort by return value; set the object's
AbortCurrent property to True instead.
How the native library is loaded
The Chilkat classes are thin wrappers over a native Chilkat library, and the loading is automatic on both platforms:
| Platform | What happens |
|---|---|
| B4A (Android) | The B4A compiler copies libchilkat_b4x.so for each ABI from the jar
into the APK, and Android's loader picks the right one for the device. Nothing to configure. |
| B4J (desktop/server) | On the first Chilkat call, the library detects the OS and CPU, extracts
the matching native binary (e.g. natives/win-x64/chilkat_b4x.dll) from the jar to a per-version
cache directory under the user profile, and loads it. Subsequent runs reuse the cached copy. Your deployed
application ships ChilkatB4J.jar and nothing else. |
Platform notes
B4A (Android)
Chilkat requires Android 7.0 or later: set minSdkVersion to 24 or higher in the project's
manifest editor. All four ABIs are included, so apps run on every current Android device and on the Android
emulator (x86 / x86_64). The 64-bit libraries support 16 KB memory pages, meeting Google Play's
requirement for apps targeting Android 15+. The usual Android rules apply to your app's code: network
operations need the INTERNET permission, and file paths should come from
File.DirInternal / scoped storage rather than hard-coded locations.
B4J (Windows, Linux, macOS)
Six platforms are supported: Windows x64, Linux x86_64, Linux arm64, Linux arm (32-bit hard-float, e.g. Raspberry Pi OS 32-bit), macOS Apple Silicon, and macOS Intel. The Java version bundled with current B4J works as-is; any Java 8+ runtime matching the platform's CPU also works.
The Linux libraries require glibc 2.27 or newer — in practice, any Linux distribution released
around mid-2018 or later (Ubuntu 18.04+, Debian 10+, RHEL/CentOS 8+, Fedora 28+, and equivalents). To check a
system, run ldd --version; the first line reports the glibc version.
The macOS native libraries are signed with Chilkat's Developer ID. They are extracted from the jar at runtime, so they never carry the browser-download quarantine attribute and Gatekeeper does not block them.
Deploying your application
There is no separate runtime to install on target machines:
| Target | Ship this | Notes |
|---|---|---|
| Android | your APK / AAB | The native libraries are already inside, one per ABI. |
| Windows / Linux / macOS | your B4J jar + ChilkatB4J.jar | Like any other B4J
additional library, ChilkatB4J.jar travels with your application (or is merged by B4J's packagers).
The native library extracts itself on first use. |
Next Steps
Browse the B4X examples for working code covering HTTP/REST, JSON, XML, email (SMTP/POP3/IMAP), FTP, SFTP/SSH, Zip, PDF, digital signatures, encryption, and much more. For questions, see the reference documentation or contact Chilkat support.
B4A, B4J, and B4X are products of Anywhere Software.