Contribute to this page on GitHub

Using Java classes

As established in the Getting Started Guide, the GraalJS JavaScript engine used by LiquidBounce's script API allows easy interoperation with Java code. Classes from the game and the Java standard library can be imported and used similarly to how you would in Java. This functionality greatly facilitates the development of powerful scripts. Basically anything possible by modifying LiquidBounce's source code can also be done using a script.

Java.type(className : string): Class

Imports a Java class.
List of parameters:

  • className, the fully qualified-name of the class to be imported.

Using classes from the Java standard library

const File = Java.type("");
const FileUtils = Java.type("");
const StandardCharsets = Java.type("java.nio.charset.StandardCharsets");

// Reads a file and returns its contents.
function readFile(path) {
  const file = new File(path);
  return FileUtils.readFileToString(file, StandardCharsets.ISO_8859_1);

For more information, please check out the official GraalJS documentation on the topic. It provides detailed instructions on how to use this functionality including many examples.