A typical C program would be compiled, assembled, linked and loaded. I know that Java works with the JVM and produces byte code. Would it be possible to connect both "object files" using the 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 the same be done between C and Java?
You can't directly link compiled C code with compiled Java code.
You can call compiled C or C++ code from Java using Java Native Interface (JNI):
The Java Native Interface (JNI) enables the integration of code written in the Java programming language with code written in other languages such as C and C++. It allows programmers to take full advantage of the Java platform without having to abandon their investment in legacy code.
This might be possible if you compile the C code to JVM bytecode, not to native code, so you would 'link' at the JVM level, not via a native object linker.
See http://en.wikipedia.org/wiki/Java_virtual_machine#C_to_bytecode_compilers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With