Using the Chilkat Java Library in Visual Studio Code

A step-by-step guide for adding the Chilkat Java library to a Java project in Visual Studio Code on Windows, Linux, and macOS. The Chilkat Java library has two parts — a JAR (the classes) and a native library — and both must be set up.

Examples: Chilkat Java Examples  ·  Documentation: Chilkat Java Reference

Download the matching build The native library must match your environment: the build for your JDK version, your operating system, and your JVM architecture (64-bit vs 32-bit; on macOS, Apple Silicon vs Intel). See Chilkat Java Downloads.
  1. Install the Java extensions

    In VS Code, install the Extension Pack for Java (from the Extensions view). It provides Java project support, the Run/Debug tools, and the Java Projects view used below. A JDK must also be installed.

  2. Download and unzip the Chilkat Java library

    From Chilkat Java Downloads, get the build for your OS and JDK, and unzip it. Each download contains the JAR and the platform's native library:

    chilkat.jar                 the Chilkat Java classes
    chilkat.dll                 native library (Windows)
    libchilkat.so              native library (Linux)
    libchilkat.jnilib          native library (macOS)

    (Your download contains the JAR plus the one native library for your platform.)

  3. Add chilkat.jar as a referenced library

    For a lightweight Java project (no Maven/Gradle), copy chilkat.jar into a lib folder in your project — VS Code adds JARs in lib to Referenced Libraries automatically.

    Or add it explicitly: open the Java Projects view in the Explorer sidebar, find Referenced Libraries, click the +, and select chilkat.jar.

    Using Maven or Gradle? Install chilkat.jar into your local repository (or declare it as a local/system dependency) instead of using a lib folder.
  4. Point the JVM at the native library (launch.json)

    The native library must be on the JVM's java.library.path at runtime. Add a vmArgs entry to your .vscode/launch.json pointing at the folder that contains the native library:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "type": "java",
          "name": "Launch Main",
          "request": "launch",
          "mainClass": "Main",
          "vmArgs": "-Djava.library.path=/path/to/chilkat"
        }
      ]
    }
    Windows

    Escape backslashes in JSON (or use forward slashes):

    "vmArgs": "-Djava.library.path=C:\\path\\to\\chilkat"

    Point it at the directory containing chilkat.dll / libchilkat.so / libchilkat.jnilib — not at the file itself.

  5. Load the library, unlock, and use Chilkat

    Load the native library once (a static block is convenient), unlock, then use any Chilkat class:

    import com.chilkatsoft.CkGlobal;
    import com.chilkatsoft.CkZip;
    
    public class Main {
    
        static {
            System.loadLibrary("chilkat");   // no "lib" prefix, no extension
        }
    
        public static void main(String[] args) {
            CkGlobal glob = new CkGlobal();
            glob.UnlockBundle("Anything for 30-day trial");
    
            CkZip zip = new CkZip();
            System.out.println(zip.version());
        }
    }
  6. Run

    Press F5 (Run and Debug), or click Run above the main method. If the Chilkat version prints in the terminal, the JAR and native library are both set up correctly.

    If you click the plain Run CodeLens and the native library isn't found, make sure you launched with the configuration that includes the vmArgs from Step 4.

Native library by platform

PlatformNative libraryNotes
Windowschilkat.dllx64 build for a 64-bit JVM, win32 for a 32-bit JVM
Linuxlibchilkat.soMatch the CPU architecture (x86_64, aarch64, …)
macOSlibchilkat.jnilibarm64 for Apple Silicon, x86_64 for Intel

In all cases, System.loadLibrary("chilkat") is the same — the JVM adds the correct prefix/extension for the platform.


macOS: clear the Gatekeeper quarantine

On macOS, a downloaded libchilkat.jnilib may be blocked by Gatekeeper with a code-signature / “cannot be opened” error. Clear the quarantine attribute:

xattr -dr com.apple.quarantine /path/to/chilkat

Common errors

“UnsatisfiedLinkError: no chilkat in java.library.path”

The native library folder isn't on java.library.path. Re-check the vmArgs in launch.json (Step 4) and confirm you launched with that configuration.

“UnsatisfiedLinkError” about a wrong architecture / ELF class / mach-o

The native library doesn't match the JVM. Make sure the download matches your JVM's architecture (64-bit vs 32-bit; on macOS, arm64 vs x86_64). Check with java -version / os.arch.

“The import com.chilkatsoft cannot be resolved”

chilkat.jar isn't on the classpath. Confirm it appears under Referenced Libraries in the Java Projects view (Step 2), then reload the window if needed.

macOS: library blocked by Gatekeeper

Clear the quarantine attribute as shown above.


← Chilkat Java Downloads