Is it possible to compile JavaScript files using RingoJS to Java class files?

370 views Asked by At

I'm creating modules in RingoJS, and I would like to compile them to Java class files. I know that it's possible to compile Rhino source files to Java class files. I was wondering if there's a way to use Mozilla's JSC tool to compile RingoJS modules and link it to the RingoJS engine so that it can be distributed as a single class file or jar file. If possible, what are the limitations of compiling RingoJS modules to Java class files.

1

There are 1 answers

0
Hannes Wallnöfer On BEST ANSWER

This is currently not supported in RingoJS. Compiling JavaScript to Java with Rhino is relatively straightforward, but module loading in Ringo is currently hard-coded to JavaScript source files.

Luckily, one of the features planned for the next rlelase is pluggable module loaders:

https://github.com/ringo/ringojs/issues/160

The idea behind this was really to support languages to compile to JavaScript such as CoffeScript, but I don't see why it shouldn't work for Java class files as well. In fact I think loading compiled class files is something we should support out if the box.

If you're interested in this feature watch the issue above or simply wait for the next release.