importLib
Imports a Java class.
Overview:
Functions:
API Reference
importLib()
importLib()Returns the specified class if it exists.
var libLoader = importLib("library-name.jar");Parameters:
className(String) Name of the class to import.library-name.jar(String): The filename of the JAR library located inside the plugin’slibsfolder.The path is relative to the plugin’s directory, typically something like:
plugins/openjs/Libs/library-name.jar
How It Works:
The library JAR is loaded at runtime, making all its public classes and resources available to your script.
After loading, you can use the returned loader object to get Java classes from the library, instantiate objects, and call methods.
This approach enables powerful extensibility by letting you integrate third-party Java libraries into your scripts.
Example:
In this example, the RiveScript chatbot Java library is loaded from the Libs folder, and its main class is instantiated for use in your script.
Important Notes
Make sure the
.jarfile is correctly placed inside theLibsfolder of your plugin, and the filename matches exactly.The library must be compatible with the Java runtime your server uses.
Loading large libraries may impact startup or script execution time.
Use
importLibonly for trusted JARs to avoid security risks.
Last updated
Was this helpful?