> For the complete documentation index, see [llms.txt](https://commandbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://commandbox.ortusbooks.com/5.0.0/task-runners/loading-ad-hoc-jars.md).

# Loading Ad hoc Jars

If you need to use a 3rd party jar, we recommend you use the extra parameters to the createObject() function, which allows you to specify a list of jars to load from (this is a Lucee-specific feature).  Read up on the `context` parameter here:

{% embed url="<http://docs.lucee.org/reference/functions/createobject.html>" %}

There are some scenarios however that don't work.  One is if you need to use the `createDynamicProxy()` BIF to create CFC instances that implement Java classes that exist in an ad hoc jar.  Lucee currently requires those classes to be loaded by the Lucee system classloader. &#x20;

As such, CommandBox gives you a mechanism to load jars into the system class loader that was used to classload Lucee so those classes are available everywhere.  This is a much better and portable solution to dropping the jars in the `~/.CommandBox/lib` folder and restarting the shell.

## classLoad()

To load up your custom jars on the fly, call the `classLoad()` method which is available in any custom command or Task Runner.

```javascript
classLoad( 'D:/amqp-client-5.1.2.jar' );
```

You can pass either an array or list of:

* D**irectories** - All jar and class files will be loaded from each directory recursively
* **Jar files** - Each jar file will be loaded
* **Class files** - Each class file will be loaded

Note, paths need to be absolute when you pass them in!  Here's some more examples.

```javascript
classLoad( 'C:/myLibs,C:/otherLibs' );
classLoad( [ 'C:/myLibs', 'C:/otherLibs' ] );
classLoad( 'C:/myLibs/myLib.jar,C:/otherLibs/other.class' );
classLoad( [ 'C:/myLibs/myLib.jar', 'C:/otherLibs/other.class' ] );
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://commandbox.ortusbooks.com/5.0.0/task-runners/loading-ad-hoc-jars.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
