请输入您要查询的百科知识:

 

词条 GIWS (software)
释义

  1. Example

  2. See also

  3. External links

{{notability|Products|date=August 2015}}{{refimprove|date=August 2015}}

GIWS is a wrapper generator intended to simplify calling Java from C or C++ by automatically generating the necessary JNI code.

GIWS is released under the CeCILL license.

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++.

  1. include
  2. include "basic_example.hxx"
  3. 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("-Djava.class.path=.");

options[1].optionString = const_cast("-Xcheck:jni");

args.options = options;

args.ignoreUnrecognized = JNI_FALSE;

JNI_CreateJavaVM(&jvm, (void **)&env, &args);

return jvm;

}

using namespace basic_example;

using namespace std;

int main(){

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

External links

  • {{Official website|https://github.com/opencollab/giws/}}
{{programming-software-stub}}

4 : Computer programming tools|Cross-platform software|Free computer programming tools|Java platform

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/12 20:08:23