Possible Duplicate:
How to access the Java method in a C++ application
I need to use JAR file in c++ program. i.e. from c++ i need to call java function, for example, In java there is a function who accept 2 integer and return addition of that, Now i need to call this function from c++. Please guide me Thanks in advance.
You need to use the Java Invocation API, described here. This example code (from that link) shows how to load in a Java Virtual Machine and use it to call a static Java method named
test
with anint
argument, located in the classMain
. In this example, the path to the JAR file would be set using thevm_args.classpath
variable.If you wanted to call a non-static method, the code would be only slightly different, and the rest of the Java Native Interface tutorial explains all you need to know.