6

What's the recommended way to embed JVM in C program with NO library. This means JVM as a eDSL execution engine. (Not whole Java platform environment) I'm trying to use another JVM based language instead of Java itself.

eonil
  • 83,476
  • 81
  • 317
  • 516
  • 1
    I remember myself playing with JamVM. It is small and written in C, and it was fairly easy to embed it. However it relies on GNU Classpass, which is quite big, and the virtual machine did not behave well in embedded environment, so I ended up writing my own Java machine. But if you're doing desktop application you might consider JamVM as an option. – Archie Aug 30 '11 at 23:08
  • 2
    Clarify "no library". Which implementation of VM have you chosen ? and it provides a static JVM implementation to link into your code ? The DSO (DLL/SO) based version is documentationed and maybe part of JNI standards to integrate with other native code. Given you are using another JVM based language you may not have issues with GNU Classpath the previous commentor indicates. – Darryl Miles Oct 19 '11 at 17:36
  • For clarity: it seems you are trying to create your own DSL that you plan to parse into JVM byte code, and you need a JVM implementation to embed into your system to execute the resulting byte code. Am I right? –  Oct 28 '11 at 21:51

2 Answers2

1

This may sound insane, but I would suggest embedding Mono and using IKVM to run your Java code. Mono is a relatively small and portable VM, which is suitable for embedding (you may even link it statically to your application) and IKVM is a faithful implementation of Java 1.6, which is capable of running even such monstrosities as Eclipse.

Using a combination of Mono/IKVM you can even compile your application Ahead-of-Time into x86 machine code (see Compiling Java Code to x86 Code).

Max Mouratov
  • 391
  • 2
  • 11
0

Maybe you want to embed some other JavaVM-s, then you might look into Kaffe, but I don't know it well and it might not answer your needs. My understanding of JVM specification is that the class loader is an essential part of it (and it needs some core classes).

What is the JVM based DSL language you want to use?

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547