Urgent!! PB write a program in C/C++ who start a JVM and invoke a method ja

I try to write a program in C/C++ who start a JVM and invoke a method java.

my program run fine if in my essai method, i do't call the JNI method ierror().

but when i call the ierror() there's a bug :

enter in essai

Exception in thread "Thread-0" java.lang.AbstractMethodError

at prog.Prog.client(Prog.java:12)

what's wrong?

Thanks for your help.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Prog.java

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package prog;

import testnative.jAppEngine;

public class Prog extends jAppEngine

{

public void main (String[] args)

{

}

public void essai();

{

System.out.println("enter in essai");

ierror();

System.out.println("quit essai");

}

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// jAppEngine.java

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public class jAppEngine

{

public native void ierror();

static

{

System.loadLibrary("jEngine");

}

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// jEngine.cpp (my jEngine.dll)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*

* Class:testnative_jAppEngine

* Method:ierror

* Signature: ()V

*/

JNIEXPORT void JNICALL Java_testnative_jAppEngine_ierror

(JNIEnv *env, jobject jobj) )

{

ierror( "Dans jAppEngine.ierror");

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Application.cpp

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

JavaVM *vm = 0;

int startJVM( )

{

char *s = 0;

int ret;

jboolean jvmspecified = JNI_FALSE;/* Assume no option specified. */

char jrepath[MAXPATHLEN], jvmpath[MAXPATHLEN];

int i, knownVMsCount;

...

...

...

...

...

...

/* If we got here, jvmpath has been correctly initialized. */

ifn.CreateJavaVM = 0;

ifn.GetDefaultJavaVMInitArgs = 0;

if (!LoadJavaVM(jvmpath, &ifn))

return 6;

/* Set default CLASSPATH */

if ((s = getenv("CLASSPATH")) == 0)

{

s = ".";

}

SetClassPath(s);

/* Initialize the virtual machine */

if (!InitializeJVM(&vm, &env, &ifn))

fprintf(stderr, "Could not create the Java virtual machine.\n");

ret = 1;

return ret;

}

int LaunchClass( char *classname, char *jentry, void *p )

{

int retval;

jclass mainClass;

jmethodID mainID;

JNIEnv *env;

retval = vm->AttachCurrentThread((void **)&env,NULL);

jcls = LoadClass(env, classname);

/* Get the application's main method */

mainID = env->GetMethodID( mainClass, jentry, "()V");

/* Invoke main method. */

env->CallVoidMethod( mainClass, mainID); //, mainArgs);

if ((*vm).DetachCurrentThread() != 0)

fprintf(stderr, "Could not detach main thread.\n");

return ret;

}

static void th1(void *p)

{

LaunchClass( "prog.Prog", "client", NULL);

_endthread();

}

int main(int argc, char* argv[])

{

startJVM();

Beep(6000,500);

for (int i=0; i<1; i++)

{

_beginthread(&th1,0,&i);

Sleep(500);

}

return 0;

}

[3964 byte] By [SANCERRY] at [2007-9-26 4:22:51]
# 1
You have implemented a native method called ierror. It calls another subroutine called ierror - somewhere. Where is that subroutine?
bschauwe at 2007-6-29 17:28:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Hi! bschauwe

Thanks for reply.

My native method called ierror calls effectively a subroutine who's in another dll. I change the name of my native method, no effects always the same error message.

So, in my native method I replace ierror(...) by Beep(..) and it's the same.

I don't understand.

SANCERRY at 2007-6-29 17:28:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
One thing I noticed is that you are using CallVoidMethod to invoke "main".This should use CallStaticVoidMethod
bschauwe at 2007-6-29 17:28:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...