ClassJS

ClassJS

A KubeJS addon to create Java classes

by
847 Downloads
forge
Rent Server with this Mod

About this Mod

ClassJS is a mod to create Java classes in KubeJS.

Basic Example

You may operate Java byte code to build your own methods.

Note: Some instructions that interacts with classes (getstatic, invokestatic, new, etc.) is protected under KubeJS's class filters. You may not use them to access classes that is not allowed by KubeJS or its other addons. Neither can you extend or implement them.

let ExampleClass = ClassCreator.create("ExampleClass")
    .toPublic()           // Set the class to public
    .defaultConstructor() // Add a default constructor
    .createMethod("exampleMethod", [], "java.lang.String") // Method name, parameter types, and return type
        .toPublic()
        .code(builder => {
            builder.pushString("Hello, ClassJS!")   // Push a string reference to the operand stack
                .returnObject();                    // Returns the string
        })
    .defineClass();     // Define the class

console.info((new ExampleClass()).exampleMethod());

Equivalent Java code:

public class ExampleClass {

    public ExampleClass() {
        super();
    }

    public String exampleMethod() {
        return "Hello, ClassJS!";
    }

}

Code in JavaScript

If you do not want to learn Java byte code, you can create methods using JavaScript functions.

let ExampleClass = ClassCreator.create("ExampleClass")
    .toPublic()
    .createMethod("exampleMethod", ["int", "int"], "int")
        .toPublic().toStatic()
        .codeJS((num1, num2) => {
            return num1 + num2;
        })
    .defineClass();

console.info(ExampleClass.exampleMethod(1, 2));
// Output in startup.log
// 3.0

Equivalent Java code:

public ExampleClass {
    
    // Note: This class do not even have a constructor,
    //         as the JavaScript above did not call `defaultConstructor`,
    //         neither did it created any other constructors.

    public static int exampleMethod(int i1, int i2) {
        return i1 + i2;
    }

}

Load a Created Class

Classes can be only defined in startup scripts.
If you want to use them in other scripts, you can use ClassJSUtils.loadClass method.

ClassCreator.create("SomeClass")
    /** Do some operations to add content to this class */
    .defineClass();

// In other scripts:

let SomeClass = ClassJSUtils.loadClass("SomeClass");
// Then you can use `SomeClass`

Available Versions

ClassJS 0.1-alpha.6alpha
MC 1.20.1forge
December 27, 2025
ClassJS 0.1-alpha.5alpha
MC 1.20.1forge
October 20, 2025
ClassJS 0.1-alpha.4alpha
MC 1.20.1forge
October 17, 2025
ClassJS 0.1-alpha.3alpha
MC 1.20.1forge
October 16, 2025
ClassJS 0.1-alpha.2alpha
MC 1.20.1forge
October 14, 2025

How to Install ClassJS on Your Server

1

Order Server

Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).

2

Set forge Loader

In the panel under "Egg", select the forge loader and matching Minecraft version (1.20.1).

3

Install Mod

Open the mod browser in the dashboard and search for "ClassJS". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.

Compatibility

Mod Loaders

forge

Minecraft Versions

1.20.1

Server-side

Required

Recommended RAM

4 GB(min. 3 GB)

Frequently Asked Questions

ClassJS server crashes on startup – what to do?

Most common cause: wrong forge version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (1.20.1). You can switch loaders with one click in the panel.

Is ClassJS compatible with forge?

ClassJS officially supports forge for Minecraft 1.20.1. The Mado dashboard automatically detects incompatible loader combinations.

Server lagging with ClassJS – how to optimize performance?

Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if ClassJS consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.

Rent Modded Server

Install ClassJS with just one click on your server.

Recommended RAM
4 GBab €8/mo
Min. 3 GB | +1 GB pro 8 Spieler
Create Server Now
1-Click Mod Install
NVMe SSD Storage
DDoS Protection included

Details

License
MIT License
Server-side
Required

Supported Versions

1.20.1