Call java from c code

Our programming model is as follows:

C-code is designed to capture real-time events (very often) of the system, and java-code is executed as a server to receive a request. When there is an event fixed by code c, we need to send a request for Java code and wait for a response. I tried JNI to call java from c, but it seems to get stuck after starting for a few seconds. JNI needs to initialize jvm and look for a handler in the class file. Is there a better way to communicate between c and java? Can I compile java code into a binary file and link it to c code? Thanks

+3
source share
3 answers

, , -/-. , C- Java , Java C-. FIFO , , , .

, Java C- , , (.. C- Java).

+3

Java , C, . Java C, .

+1

One option is to run the Java application in a separate process and use the interprocess communications between the Java application and the C data collector.

As for compiling Java and referencing C, this is possible if your toolbox supports it. For example, if you use the full-featured GNU compiler, gcc and gcj can work together, however you need to understand that Java is not just a language, but also an environment. Doing your own compilation of Java may not give you any reason why you are using Java for the system.

+1
source

All Articles