Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling C++ for the JVM

When compiling C++ you of course use a compiler for the target platform you want to compile for. Is there a C++ compiler that targets the JVM (so instead of using the Java "native" interface C++ code is compiled to Java byte code)?

like image 386
knpwrs Avatar asked Nov 19 '10 02:11

knpwrs


People also ask

Can C run on JVM?

Yes. Here's a commercial C compiler that produces JVM bytecode.

Can C be compiled to Java bytecode?

Axiomatic Solutions has an answer to this problem called Axiomatic Multi-Platform C (AMPC). This software can compile C source files directly into Java class files.

Does JVM compile?

Modern JVMs take bytecode and compile it into native code when first needed.

Does Java compile to C?

The JVM (Java Virtual Machine) may be an interpreter or a JIT (Just In Time) compiler or both. If it is a compiler then it is writing machine code directly. It does not write C code first.


1 Answers

NestedVM provides binary translation for Java Bytecode. This is done by having GCC compile to a MIPS binary which is then translated to a Java class file. Hence any application written in C, C++, Fortran, or any other language supported by GCC can be run in 100% pure Java with no source changes.

like image 98
ephemient Avatar answered Sep 18 '22 20:09

ephemient