本文整理汇总了C++中VirtualMachine::Call方法的典型用法代码示例。如果您正苦于以下问题:C++ VirtualMachine::Call方法的具体用法?C++ VirtualMachine::Call怎么用?C++ VirtualMachine::Call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine::Call方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
(void)argc;
(void)argv;
VirtualMachine vm;
vm.LoadFile("script.as");
vm.Call("void main()");
JavaVM *jvm; /* denotes a Java VM */
JNIEnv *env; /* pointer to native method interface */
JavaVMInitArgs vm_args; /* JDK/JRE 6 VM initialization arguments */
JavaVMOption* options = new JavaVMOption[1];
options[0].optionString = "-Djava.class.path=/usr/lib/java";
vm_args.version = JNI_VERSION_1_6;
vm_args.nOptions = 1;
vm_args.options = options;
vm_args.ignoreUnrecognized = false;
/* load and initialize a Java VM, return a JNI interface
* pointer in env */
JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
delete options;
/* invoke the Main.test method using the JNI */
jclass cls = env->FindClass("Main");
jmethodID mid = env->GetStaticMethodID(cls, "test", "(I)V");
env->CallStaticVoidMethod(cls, mid, 100);
/* We are done. */
jvm->DestroyJavaVM();
std::cout << "Hello World! (C++)" << std::endl;
}
示例2: main
int main(int argc, char** argv)
{
(void)argc;
(void)argv;
VirtualMachine vm;
vm.LoadFile("script.as");
vm.Call("void main()");
std::cout << "Hello World! (C++)" << std::endl;
}