Forum: JRuby API to invoke Java compilation

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C19c27f3c5edb34542e4a906be116983?d=identicon&s=25 Federico Tomassetti (ftomassetti)
on 2013-11-13 10:41
I wonder if there is any API in JRuby to invoke the Java compiler.
I would like to load some Java source file, compile it on the fly and
run it. I am ware of the Java Compiler API and I was about to wrap it in
a new project (, I
would like just to avoid repeating something already done...

B97f192e676f1a67e0ef18f022671406?d=identicon&s=25 Rodrigo Botafogo (Guest)
on 2013-11-13 16:29
(Received via mailing list)

Ive looked a lot at this type of API and couldnt find anything.  I
presumed that there is no such library for JRuby.  I wanted to use this
MDArray, but left it for a future versions.  I think that an easy to use
the fly compiler will be great for JRuby.  The easiest compiler I found
Janino.  The Java Compiler API, if Im not mistaken, requires the
of a file and then reads this file (seemed like a lot of work and could
have security implications).  Janino, I believe, does this without the

Good luck!


On Wed, Nov 13, 2013 at 7:41 AM, Federico Tomassetti
C19c27f3c5edb34542e4a906be116983?d=identicon&s=25 Federico Tomassetti (ftomassetti)
on 2013-11-13 17:33
I think you can use the Compiler API to work in memory: you have to
crate some dummy classes representing a Java source file which are not
tied to a real file but just have the code in memory. The problem with
Compiler API on my side is that they requires the JDK. I don't like that
much the idea to be dependent on the configuration of the user.

I would consider ASM, CGLIB and this Janino that you suggest.

If you are interested I could use an helping hand on that :)

This topic is locked and can not be replied to.