Java support for Roblox [JBlox]

Hi, so im working on JBlox which is just an interpreter for java in roblox.
Yeah so you can code in Java basically.

heres an example code:

local JBlox = require(script.Parent.JBlox)

JBlox.JRun([[
import roblox.*;

public class SpawnPart {
    public static void main(String[] args) {
        String myString = new String("Hello");
        int myInt = new int(42);
        char myChar = new char("A");
        double myDouble = new double(3.14);
        Color3 myColor = new Color3("Bright blue");
        BrickColor myBrickColor = new BrickColor("Bright red");
        Vector3 myVector = new Vector3(10, 10, 5);
        
        Instance myPart = new Instance("Part");
        myPart.Anchored = true;
        myPart.Size = myVector;
        myPart.BrickColor = myBrickColor;
        myPart.Parent = workspace;
    }
}
]])

heres the early version module with lots of errors:

JBlox.lua (3.3 KB)

10 Likes

Curious, is this for like a project ? IF you want access to types and such, why not use use typed Luau?

I am not saying what you have done is not cool, just curious as to what is gained by doing it this way?

1 Like

i thought it may be easier for java/C# devs to maybe transfer to roblox by using the java syntax

1 Like

Check out MiddleClass on github. I came from C# and it made working won’t lua like 1000x easier to me. I rave that its the perfect OOP language, and it even comes with self checking like an instance to registered classes in the core module.

It has just the right sugar, and robust implementation to not be too much overhead for class definition but enough to be readable and informative.

But again, I applaud the practice its always cool to see things like that. =-)

1 Like

Awesome! Get this on Github. I’ll contribute something to it.

1 Like

OMG I LIKE PROGRAMMING IN JAVA AND SUFFER BY 192891919 EXCEPTIONS
IMA USE THIS VERY 10/10 THING

complete sentence

1 Like

I recommend using Lux for the grammar

2 Likes

seriously java in roblox?, reply “…” if you are kidnaped

6 Likes

creating a massive compatibility layer for a language everyone hates is wild

1 Like

you should make a transpiler to convert java to lua code, instead of interpreting the java code during runtime, here’s why:

  • performance is going to be a lot better since the interpreting is already done beforehand
  • there will be no need for loadstring to be enabled (security risk & performance is going to further suffer)
  • type annotations & plugins can be used because the java code can be written in an actual IDE instead of a string

you should take a look at roblox-ts because it’s a similar project to yours