Java compiler object code (byte code?)
A typical C program will be compiled, built, linked, and loaded. I know Java works with JVM and generates bytecode. Is it possible to link both "object files" using a linker? For example, a C program and a C ++ program can be used together by playing with the linker and linking both object files.
Can this be done between C and Java?
You cannot directly link the compiled C code to the compiled Java code.
You can call compiled C or C ++ code from Java using Java Native Interface (JNI) :
Java Native Interface (JNI) allows you to integrate code written in the Java programming language with code written in other languages, such as C and C ++. This allows programmers to take full advantage of the Java platform without having to give up their investment in legacy code.
This might be possible if you compile the C code to JVM bytecode rather than native code, so that you will "link" at the JVM level, rather than through your own linker object.
See http://en.wikipedia.org/wiki/Java_virtual_machine#C_to_bytecode_compilers
No, at least not with shared tools. The "object file" that javac
produces is (informally) called "bytecode" and is a device-independent representation of the program for the stack (not much different from that used for the old "P-Code" ).
There are various tools out there that can translate Java bytecodes into executables for different hardware architectures, but they are all pretty specialized - none of them know what creates the associated modules.
GCC can compile Java files into a class and then into executable assembler code usinggcj
AFAIK, it's impractical to combine Java and C directly, but the machine code should end up in a form that a normal linker can understand. You probably need some kind of assembler glue code to call in between.