Function appendClasspath

  • Append a single or multiple jars to the class path.

    Just replaces the old internal class loader with a new one containing the new jars. This doesn't check if the jars are valid and/or even exist. The new classpath will be available to all classes imported after this call.

    If you want to import whole directories, you can use glob patterns.

    import { appendClasspath } from 'java-bridge';

    // Append a single jar to the class path
    appendClasspath('/path/to/jar.jar');

    // Append multiple jars to the class path
    appendClasspath(['/path/to/jar1.jar', '/path/to/jar2.jar']);

    or

    import { classpath } from 'java-bridge';

    // Append a single jar to the class path
    classpath.append('/path/to/jar.jar');
    import { appendClasspath } from 'java-bridge';

    // Append a directory to the class path
    appendClasspath('/path/to/dir/*');
    // Append just the jar files in the directory
    appendClasspath('/path/to/dir/*.jar');

    Parameters

    • path: string | string[]

      the path(s) to add

    Returns void