Call JNI_CreateJavaVM from C++ returns (-1)

S

Steve

Hi

I am trying to Create the JVM with no luck
I always get a -1 from the CreateJaveVM

I have jvm.dll in \WINNT\System32

Are there other dll or libraries that I need in my search path???

Any other suggestions???

Thanks
Steve




#include "C:\JBuilder9\jdk1.4\include\jni.h"
#include "SimpleJ.h"

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
long result;

JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs vm_args;

JavaVMOption options[1];

vm_args.version = JNI_VERSION_1_4;
vm_args.nOptions = 1;
options[0].optionString = "-Djava.class.path=C:\\WINNT\\java\\classes";

vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_FALSE;

result = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
if (result < 0)
{
MessageBox(NULL, "Error Create JAVAVM", "JAVA VM", MB_OK);
return -1;

}
 
S

Silvio Bierman

Steve said:
Hi

I am trying to Create the JVM with no luck
I always get a -1 from the CreateJaveVM

I have jvm.dll in \WINNT\System32

Are there other dll or libraries that I need in my search path???

Any other suggestions???

Thanks
Steve




#include "C:\JBuilder9\jdk1.4\include\jni.h"
#include "SimpleJ.h"

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
long result;

JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs vm_args;

JavaVMOption options[1];

vm_args.version = JNI_VERSION_1_4;
vm_args.nOptions = 1;
options[0].optionString = "-Djava.class.path=C:\\WINNT\\java\\classes";

vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_FALSE;

result = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
if (result < 0)
{
MessageBox(NULL, "Error Create JAVAVM", "JAVA VM", MB_OK);
return -1;

}

Yes, you need a decently installed JRE, not just a DLL.

Silvio Bierman
 
S

Steve

Hi Silvio

I installed JBuilder which looks like it installed jdk1.4 under itself.

do you know if the JRE directory needs to be in the Windows PAth or the JRE
files
need to be installed somewhere else?

Thanks
Steve

Silvio said:
Steve said:
Hi

I am trying to Create the JVM with no luck
I always get a -1 from the CreateJaveVM

I have jvm.dll in \WINNT\System32

Are there other dll or libraries that I need in my search path???

Any other suggestions???

Thanks
Steve




#include "C:\JBuilder9\jdk1.4\include\jni.h"
#include "SimpleJ.h"

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
long result;

JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs vm_args;

JavaVMOption options[1];

vm_args.version = JNI_VERSION_1_4;
vm_args.nOptions = 1;
options[0].optionString = "-Djava.class.path=C:\\WINNT\\java\\classes";

vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_FALSE;

result = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
if (result < 0)
{
MessageBox(NULL, "Error Create JAVAVM", "JAVA VM", MB_OK);
return -1;

}

Yes, you need a decently installed JRE, not just a DLL.

Silvio Bierman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top