> For the complete documentation index, see [llms.txt](https://emotiv.gitbook.io/cortex-library-for-mobile/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emotiv.gitbook.io/cortex-library-for-mobile/java-api/cortexlib-class.md).

# CortexLib class

```java
import com.emotiv.CortexLib;
```

Use CortexLib to initialize the Cortex library. You must [load](/cortex-library-for-mobile/java-api/emotivlibraryloader-class.md) the Cortex library before using CortexLib.

## start

```java
public static boolean start(CortexLibInterface cortexLibInterface)
```

Call this static method to initialize the Cortex library. You must call it exactly once. You must call it before creating an instance of the [CortexClient class](/cortex-library-for-mobile/objective-c-api/cortexclient-class.md). The library starts asynchronously. When it is started, the library calls the callback you provided.

```java
public interface CortexLibInterface {
    public void onCortexStarted();
}
```

## stop

```java
public static void stop()
```

Call this static method to stop the Cortex library. You must call it exactly once.

## setLogHandler

```java
public static void setLogHandler(CortexLogLevel logLevel, CortexLogHandler logHandler)
```

Call this method if you want to receive the log messages from the Cortex library.

Calling this method is optional. However, if you want to call it, then you must do it before calling the method `start`.

The parameter **logLevel** controls how much log messages you will receive.

* INFO: get all the messages
* WARNING: only get the warnings and the error messages
* ERROR: only get the error messages

```java
public enum CortexLogLevel {
    INFO,
    WARNING,
    ERROR
}
```

The parameter **logHandler** is a callback that will receive the log messages.

```java
public interface CortexLogHandler {
    public void onCortexLogMessage(String message);
}
```
