starting Java VM using JNI?
Wieger Wesselink
j_wesselink at chello.nl
Wed Mar 21 19:24:47 EST 2001
I'm trying to start a Java VM in Python using JNI, with the following
C++ code:
void start()
{
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
JavaVMOption options[2];
options[0].optionString = "-Djava.class.path=D:\\java";
vm_args.version = 0x00010002;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
jint res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0) {
exit(1);
}
}
That appears to work, but there is a problem. After invoking the
function
start() in Python, the interepreter generates syntax errors after each
subsequent input (see below). Can someone tell me how to fix this, or is
there a better way to start the JVM?
Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import mymodule
>>> mymodule.start()
>>>
File "<stdin>", line 1
^
SyntaxError: invalid syntax
>>>
Best regards,
Wieger
More information about the Python-list
mailing list