---
product: Chilkat
product_version: 11.7.0
language: java2
language_label: Chilkat2 Java
document: language guide
---
> Chilkat 11.7.0 · language=java2 · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/java2/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/java2/classes/<Class>.md`

# Chilkat for Chilkat2 Java — language guide — v11.7.0

> This guide has only generated sections so far. The class pages carry the per-member detail.

## Object creation, unlocking and error handling

**Object Creation**

```java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Global;

try (Global global = new Global()) {
    // ... use global ...
} catch (ChilkatException e) {
    System.out.println(e.getMessage());          // "Global.someMethod failed: <reason>"
    System.out.println(e.getLastErrorText());    // the full log of the failed call
}
```

`public Global()`

Creates the underlying native Chilkat object. The native library (`chilkat2java`) is loaded the first time any Chilkat2 object is created; see the README in the download for where it is looked for (`-Dchilkat2.library.path`, a classpath resource, or `java.library.path`).

`public void close()`

Releases the native object (`Global` is `AutoCloseable`, so try-with-resources calls it). Calling it again does nothing; any other method or property accessor called afterwards throws `IllegalStateException`. An object that is never closed is freed by a background cleaner once it becomes unreachable, but the garbage collector does not see native memory, so closing is the normal path. Objects returned by methods are owned by the caller too.

`public boolean isClosed()`

Returns `true` once `close()` has been called.

**Errors**

A method that fails throws `ChilkatException`, an unchecked exception carrying `getClassName()`, `getMethodName()`, `getReason()` (one line, also in the message) and `getLastErrorText()` (the full log, captured at the moment of the failure). The object remains usable. Methods that look something up and find nothing return `null` instead of throwing (each such method says so), and methods that answer a question (`hasMember`, `isUnlocked`, ...) return a plain `boolean`. Property accessors do not throw for Chilkat reasons.

A `null` string or object argument throws `NullPointerException` naming the parameter (except where a method documents that `null` is accepted), and a string containing U+0000 throws `IllegalArgumentException`.

Use an object from one thread at a time; it may be handed from one thread to another. The one cross-thread operation is setting `setAbortCurrent(true)` on an object that is busy in another thread (on the classes that have `AbortCurrent`). Unlocking: call `new Global().unlockBundle("...")` once at startup.

Literals in Chilkat2 Java: true is `true`, false is `false`, null/none is `null`.

## Classes

[Class index for Chilkat2 Java](https://www.chilkatsoft.com/ai-docs/v/11.7.0/java2/index.md)
