---
title: "cheerpjRunLibrary"
source: "https://cheerpj.com/docs/reference/cheerpjRunLibrary"
---

# cheerpjRunLibrary

Load a Java Library

Loads a Java library for use in JavaScript. See [library mode](https://cheerpj.com/docs/guides/library-mode.md) for more information.

```ts
async function cheerpjRunLibrary(classPath: string): Promise<CJ3Library>;
```

## Parameters

- **classPath (`string`)** - The path to the library’s jar file in the [virtual filesystem](https://cheerpj.com/docs/explanation/File-System-support.md). Pass an empty string to load the standard library only.

## Returns

`cheerpjRunLibrary` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which resolves to a [CJ3Library](https://cheerpj.com/docs/reference/CJ3Library.md) object.

## Examples

### Using the standard library

```js
await cheerpjInit();
const lib = await cheerpjRunLibrary("");


const System = await lib.java.lang.System;
await System.out.println("Hello from Java");
```

### Using a custom library

Let’s say we had a library called `example.jar` compiled from the following class:

```java
package com.example;


public class Example {
  public String[] greetings = {"Hello", "Bye"};
  public void hello() {
    System.out.println("Example says hello!");
  }
}
```

With `example.jar` being available on the web server at `/example.jar`, we could use it like so:

```js
await cheerpjInit();
const lib = await cheerpjRunLibrary("/app/example.jar");


const Example = await lib.com.example.Example;
const example = await new Example();
await example.hello(); // Example says hello!
```
