GIWS (software)
Example
The following Java class does some simple computation.
package basic_example;
import java.lang.Math;
public class MyComplexClass{
public MyComplexClass(){
// the constructor
}
public long myVeryComplexComputation(double a, double b){
return Math.round(Math.cos(a)+Math.sin(b)*9);
}
}
GIWS gives the capability to call it from C++.
- include
- include "basic_example.hxx"
- include
JavaVM* create_vm() {
JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs args;
JavaVMOption options[2];
args.version = JNI_VERSION_1_4;
args.nOptions = 2;
options[0].optionString = const_cast
options[1].optionString = const_cast
args.options = options;
args.ignoreUnrecognized = JNI_FALSE;
JNI_CreateJavaVM(&jvm, (void **)&env, &args);
return jvm;
}
using namespace basic_example;
using namespace std;
int main(){
JavaVM* jvm = create_vm();
MyComplexClass *testOfMyClass = new MyComplexClass(jvm);
cout << "My Computation: " << testOfMyClass->myVeryComplexComputation(1.2,80) << endl;
return 0;
}
To generate the binding, GIWS uses a XML declaration. GIWS will generate the JNI code to call the Java object.
See also
- SWIG allows one to call C or C++ from higher level languages
References
{{reflist}}
External links
- {{Official website|https://github.com/opencollab/giws/}}
Category:Cross-platform software
Category:Free computer programming tools
{{programming-software-stub}}