2 Replies Latest reply: Feb 5, 2010 4:14 PM by jschellSomeoneStoleMyAlias RSS

    c++ - creating Java vm problem. JNI ... exits with code 0x1

      I tried to create jvm to call java functions from C++ code and vice versa
      (i have directx renderer in c++ and I want to use java for game code)
      first I wanted to check out how it works with simple console application,
      but it crash:
      #include <jni.h>
      #include <conio.h>
      #include <iostream>
      #pragma comment(lib,"jvm.lib");
      #include <stdio.h>
      JNIEnv* create_vm() {
      JavaVM* jvm;
      JNIEnv* env;
      JavaVMInitArgs args;
      JavaVMOption options[1];
      / *There is a new JNI_VERSION_1_4, but it also doesnt work.* /
      args.version = JNI_VERSION_1_2;
      args.nOptions = 1;
      options[0].optionString = "-Djava.class.path=c:\\projects\\local\\inonit\\classes";
      args.options = options;
      args.ignoreUnrecognized = JNI_FALSE;
      JNI_CreateJavaVM(&jvm, (void )&env, &args); //exit with code 1 (0x1)
      return env;
      int main(int argc, char **argv) {*
      *JNIEnv* env = create_vm();
      //invoke_class( env );
      It quits at JNI_CreateJavaVM(&jvm, (void )&env, &args);
      - The program '[3084] test.exe: Native' has exited with code 1 (0x1).
      anyone know why? Or can help me somehow with solving this problem?
      I tried chaning options[0].optionString to path to the classes stuff of jdk examples but it doesnt change anything...
      any help appreciated...
      ps I hope that the I posted this question in right forum, if not, please dont shout at me :)